1
2
3
4
5
6
7
8 package org.codehaus.spice.netserve.sockets;
9
10 import java.io.IOException;
11 import java.net.InetAddress;
12 import java.net.Socket;
13
14 /***
15 * Service used to create client sockets. The factory is used so that
16 * the exact socket type and underlying transport is abstracted. The
17 * sockets created could be proxied, SSL enabled, TLS enabled etc.
18 * However clients just care that they return sockets.
19 *
20 * @author Peter Donald
21 * @version $Revision: 1.2 $ $Date: 2004/03/21 23:43:00 $
22 */
23 public interface SocketFactory
24 {
25 /***
26 * Create a socket that connects to specified remote address.
27 *
28 * @param address the remote address
29 * @param port the remote port
30 * @return the socket connected to remote address
31 * @throws IOException if unable to create socket
32 */
33 Socket createSocket( InetAddress address, int port )
34 throws IOException;
35
36 /***
37 * Create a socket that connects to specified remote address and
38 * originates from specified local address.
39 *
40 * @param address the remote address
41 * @param port the remote port
42 * @param localAddress the local address
43 * @param localPort the local port
44 * @return the socket connected to remote address
45 * @throws IOException if unable to create socket
46 */
47 Socket createSocket( InetAddress address, int port,
48 InetAddress localAddress, int localPort )
49 throws IOException;
50 }