01: /*
02: * Copyright (C) The Spice Group. All rights reserved.
03: *
04: * This software is published under the terms of the Spice
05: * Software License version 1.1, a copy of which has been included
06: * with this distribution in the LICENSE.txt file.
07: */
08: package org.codehaus.spice.netserve.sockets.impl;
09:
10: import java.io.IOException;
11: import java.net.InetAddress;
12: import java.net.Socket;
13: import org.codehaus.spice.netserve.sockets.SocketFactory;
14:
15: /**
16: * A SocketFactory that creates vanilla sockets.
17: *
18: * @author Peter Donald
19: * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:59 $
20: * @dna.component
21: * @dna.service type="SocketFactory"
22: */
23: public class DefaultSocketFactory implements SocketFactory {
24: /**
25: * Create a socket that connects to specified remote address.
26: *
27: * @param address the remote address
28: * @param port the remote port
29: * @return the socket connected to remote address
30: * @throws IOException if unable to create socket
31: */
32: public Socket createSocket(final InetAddress address, final int port)
33: throws IOException {
34: return new Socket(address, port);
35: }
36:
37: /**
38: * Create a socket that connects to specified remote address and
39: * originates from specified local address.
40: *
41: * @param address the remote address
42: * @param port the remote port
43: * @param localAddress the local address
44: * @param localPort the local port
45: * @return the socket connected to remote address
46: * @throws IOException if unable to create socket
47: */
48: public Socket createSocket(final InetAddress address,
49: final int port, final InetAddress localAddress,
50: final int localPort) throws IOException {
51: return new Socket(address, port, localAddress, localPort);
52: }
53: }
|