public abstract class SocketFactory extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
SocketFactory()
Creates a new
SocketFactory instance. |
| Modifier and Type | Method and Description |
|---|---|
Socket |
createSocket()
Creates a new socket which is not connected to any remote host.
|
abstract Socket |
createSocket(InetAddress host,
int port)
Creates a new socket which is connected to the remote host specified by
the InetAddress
host. |
abstract Socket |
createSocket(InetAddress address,
int port,
InetAddress localAddress,
int localPort)
Creates a new socket which is connected to the remote host specified by
the InetAddress
address. |
abstract Socket |
createSocket(String host,
int port)
Creates a new socket which is connected to the remote host specified by
the parameters
host and port. |
abstract Socket |
createSocket(String host,
int port,
InetAddress localHost,
int localPort)
Creates a new socket which is connected to the remote host specified by
the parameters
host and port. |
static SocketFactory |
getDefault()
Gets the default socket factory of the system which can be used to create
new sockets without creating a subclass of this factory.
|
static void |
setDefault(SocketFactory socketFactory)
Set the default socket factory.
|
public static SocketFactory getDefault()
public static void setDefault(SocketFactory socketFactory)
public Socket createSocket() throws IOException
SocketException is thrown.IOException - if an error occurs while creating a new socket.public abstract Socket createSocket(String host, int port) throws IOException, UnknownHostException
host and port. The socket is bound to any
available local address and port.host - the remote host address the socket has to be connected to.port - the port number of the remote host at which the socket is
connected.IOException - if an error occurs while creating a new socket.UnknownHostException - if the specified host is unknown or the IP address could not
be resolved.public abstract Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException
host and port. The socket is bound to the
local network interface specified by the InetAddress localHost on
port localPort.host - the remote host address the socket has to be connected to.port - the port number of the remote host at which the socket is
connected.localHost - the local host address the socket is bound to.localPort - the port number of the local host at which the socket is
bound.IOException - if an error occurs while creating a new socket.UnknownHostException - if the specified host is unknown or the IP address could not
be resolved.public abstract Socket createSocket(InetAddress host, int port) throws IOException
host. The socket is bound to any available local
address and port.host - the host address the socket has to be connected to.port - the port number of the remote host at which the socket is
connected.IOException - if an error occurs while creating a new socket.public abstract Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException
address. The socket is bound to the local network
interface specified by the InetAddress localHost on port localPort.address - the remote host address the socket has to be connected to.port - the port number of the remote host at which the socket is
connected.localAddress - the local host address the socket is bound to.localPort - the port number of the local host at which the socket is
bound.IOException - if an error occurs while creating a new socket.