Package org.jboss.logmanager.handlers
Interface ClientSocketFactory
-
public interface ClientSocketFactoryA factory used to create writable sockets.- Author:
- James R. Perkins
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.net.DatagramSocketcreateDatagramSocket()Creates a datagram socket for UDP communication.java.net.SocketcreateSocket()Creates a TCP socket.java.net.InetAddressgetAddress()Returns the address being used to create sockets.intgetPort()Returns the port being used to create sockets.default java.net.SocketAddressgetSocketAddress()A convenience method to return the socket address.static ClientSocketFactoryof(java.net.InetAddress address, int port)Creates a new default implementation of the factory which usesSocketFactory.getDefault()for TCP sockets andnew DatagramSocket()for UDP sockets.static ClientSocketFactoryof(javax.net.SocketFactory socketFactory, java.net.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 Detail
-
createDatagramSocket
java.net.DatagramSocket createDatagramSocket() throws java.net.SocketExceptionCreates a datagram socket for UDP communication.- Returns:
- the newly created socket
- Throws:
java.net.SocketException- if binding the socket fails
-
createSocket
java.net.Socket createSocket() throws java.io.IOExceptionCreates a TCP socket.- Returns:
- the newly created socket
- Throws:
java.io.IOException- if an error occurs creating the socket
-
getAddress
java.net.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
default java.net.SocketAddress getSocketAddress()
A convenience method to return the socket address.The default implementation simply returns
new InetSocketAddress(getAddress(), getPort()).- Returns:
- a socket address
-
of
static ClientSocketFactory of(java.net.InetAddress address, int port)
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
static ClientSocketFactory of(javax.net.SocketFactory socketFactory, java.net.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.- Parameters:
socketFactory- the socket factory used for TCP connections, ifnullthe default socket factory will be usedaddress- the address to bind toport- the port to bind to- Returns:
- the client socket factory
-
-