public interface ClientSocketFactory
| Modifier and Type | Method and Description |
|---|---|
DatagramSocket |
createDatagramSocket()
Creates a datagram socket for UDP communication.
|
Socket |
createSocket()
Creates a TCP socket.
|
InetAddress |
getAddress()
Returns the address being used to create sockets.
|
int |
getPort()
Returns the port being used to create sockets.
|
default SocketAddress |
getSocketAddress()
A convenience method to return the socket address.
|
static ClientSocketFactory |
of(InetAddress address,
int port)
Creates a new default implementation of the factory which uses
SocketFactory.getDefault() for TCP
sockets and new DatagramSocket() for UDP sockets. |
static ClientSocketFactory |
of(SocketFactory socketFactory,
InetAddress address,
int port)
Creates a new default implementation of the factory which uses the provided
socket factory to create TCP connections and
new DatagramSocket() for UDP sockets. |
DatagramSocket createDatagramSocket() throws SocketException
SocketException - if binding the socket failsSocket createSocket() throws IOException
IOException - if an error occurs creating the socketInetAddress getAddress()
int getPort()
default SocketAddress getSocketAddress()
The default implementation simply returns new InetSocketAddress(getAddress(), getPort()).
static ClientSocketFactory of(InetAddress address, int port)
SocketFactory.getDefault() for TCP
sockets and new DatagramSocket() for UDP sockets.address - the address to bind toport - the port to bind tostatic ClientSocketFactory of(SocketFactory socketFactory, InetAddress address, int port)
new DatagramSocket() for UDP sockets.socketFactory - the socket factory used for TCP connections, if null the
default socket factory will be usedaddress - the address to bind toport - the port to bind toCopyright © 2019 JBoss by Red Hat. All rights reserved.