Package org.jboss.logmanager.handlers
Interface ClientSocketFactory
public interface ClientSocketFactory
A factory used to create writable sockets.
- Author:
- James R. Perkins
-
Method Summary
Modifier and TypeMethodDescriptionCreates a datagram socket for UDP communication.Creates a TCP socket.Returns the address being used to create sockets.int
getPort()
Returns the port being used to create sockets.default SocketAddress
A convenience method to return the socket address.static ClientSocketFactory
of
(InetAddress address, int port) Creates a new default implementation of the factory which usesSocketFactory.getDefault()
for TCP sockets andnew 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 andnew DatagramSocket()
for UDP sockets.
-
Method Details
-
createDatagramSocket
Creates a datagram socket for UDP communication.- Returns:
- the newly created socket
- Throws:
SocketException
- if binding the socket fails
-
createSocket
Creates a TCP socket.- Returns:
- the newly created socket
- Throws:
IOException
- if an error occurs creating the socket
-
getAddress
InetAddress getAddress()Returns the address being used to create sockets.- Returns:
- the address being used
-
getPort
int getPort()Returns the port being used to create sockets.- Returns:
- the port being used
-
getSocketAddress
A convenience method to return the socket address.The default implementation simply returns
new InetSocketAddress(getAddress(), getPort())
.- Returns:
- a socket address
-
of
Creates a new default implementation of the factory which usesSocketFactory.getDefault()
for TCP sockets andnew DatagramSocket()
for UDP sockets.- Parameters:
address
- the address to bind toport
- the port to bind to- Returns:
- the client socket factory
-
of
Creates a new default implementation of the factory which uses the provided socket factory to create TCP connections andnew DatagramSocket()
for UDP sockets.- Parameters:
socketFactory
- the socket factory used for TCP connections, ifnull
the default socket factory will be usedaddress
- the address to bind toport
- the port to bind to- Returns:
- the client socket factory
-