This interface is used as a heap to control the allocation of sockets. An instance of this interface can be passed to methods that allocate sockets. In this way, the actual, underlying type of socket allocated can be replaced (for instance, with an SSL socket or an firewall-tunnelling socket),
| 109 | * @version 2.2 |
| 110 | */ |
| 111 | public interface SocketFactory |
| 112 | { |
| 113 | /** |
| 114 | * The default socket factory. It just creates a standard |
| 115 | * <code>Socket</code> to the specified host and port, and is exactly |
| 116 | * equivalent to calling <code>new Socket(host, port)</code>. |
| 117 | */ |
| 118 | public final SocketFactory defaultFactory = new DefaultSocketFactory(); |
| 119 | |
| 120 | /** |
| 121 | * Creates a new <code>Socket</code> that talks to the specified port |
| 122 | * on the named host. |
| 123 | * <p> |
| 124 | * The implementation may choose any way it wants to provide a |
| 125 | * socket-like object (essentially any mechanism that supports |
| 126 | * bidirectional communication). The returned <code>Socket</code> (or |
| 127 | * subclass of <code>Socket</code>) might not be based on TCP/IP, or it |
| 128 | * might involve running a TCP/IP stack over some other protocol, or it |
| 129 | * might actually redirect all connections via some other proxy machine, |
| 130 | * etc. |
| 131 | * |
| 132 | * @param host |
| 133 | * The host name. |
| 134 | * |
| 135 | * @param port |
| 136 | * The port number. |
| 137 | * |
| 138 | * @return An object that provides socket-like communication. |
| 139 | * |
| 140 | * @throws IOException |
| 141 | * If there is some problem establishing the socket to the |
| 142 | * specified port on the named host. |
| 143 | */ |
| 144 | public Socket newSocket(String host, int port) throws IOException; |
| 145 | } |
| 146 | |
| 147 | class DefaultSocketFactory |
| 148 | implements SocketFactory |
no outgoing calls
no test coverage detected