Class AFSocketFactory.FixedAddressSocketFactory
java.lang.Object
javax.net.SocketFactory
org.newsclub.net.unix.AFSocketFactory<AFSocketAddress>
org.newsclub.net.unix.AFSocketFactory.FixedAddressSocketFactory
- All Implemented Interfaces:
AFSocketAddressFromHostname<AFSocketAddress>
- Enclosing class:
AFSocketFactory<A extends AFSocketAddress>
public static final class AFSocketFactory.FixedAddressSocketFactory
extends AFSocketFactory<AFSocketAddress>
A socket factory that always connects to a fixed socket address, no matter what.
-
Nested Class Summary
Nested classes/interfaces inherited from class AFSocketFactory
AFSocketFactory.FixedAddressSocketFactoryModifier and TypeClassDescriptionstatic final classA socket factory that always connects to a fixed socket address, no matter what. -
Constructor Summary
ConstructorsConstructorDescriptionFixedAddressSocketFactory(SocketAddress address) Creates aAFSocketFactory.FixedAddressSocketFactory. -
Method Summary
Modifier and TypeMethodDescriptionaddressFromHost(String host, int port) Translates a "host" string (and port) to anAFSocketAddress.protected SocketconnectTo(AFSocketAddress addr) Creates a newAFSocket, connected to the given address.booleanisHostnameSupported(String host) Checks whether the given hostname is supported by this socket factory.Methods inherited from class AFSocketFactory
createSocket, createSocket, createSocket, createSocket, isInetAddressSupportedModifier and TypeMethodDescriptionfinal SocketcreateSocket(String host, int port) final SocketcreateSocket(String host, int port, InetAddress localHost, int localPort) final SocketcreateSocket(InetAddress address, int port) final SocketcreateSocket(InetAddress address, int port, InetAddress localAddress, int localPort) protected final booleanisInetAddressSupported(InetAddress address) Checks whether the givenInetAddressis supported by this socket factory.Methods inherited from class SocketFactory
getDefault
-
Constructor Details
-
FixedAddressSocketFactory
Creates aAFSocketFactory.FixedAddressSocketFactory.- Parameters:
address- The address to use for all connections.
-
-
Method Details
-
isHostnameSupported
Description copied from interface:AFSocketAddressFromHostnameChecks whether the given hostname is supported by this socket factory. If not, calls to createSocket will cause aSocketException.- Parameters:
host- The host to check.- Returns:
trueif supported.
-
addressFromHost
Description copied from interface:AFSocketAddressFromHostnameTranslates a "host" string (and port) to anAFSocketAddress.- Parameters:
host- The hostnameport- The port, or 0.- Returns:
- The
AFSocketAddress - Throws:
SocketException- If there was a problem converting the hostname
-
createSocket
- Specified by:
createSocketin classAFSocketFactory<AFSocketAddress>- Throws:
SocketException
-
connectTo
Description copied from class:AFSocketFactoryCreates a newAFSocket, connected to the given address.- Specified by:
connectToin classAFSocketFactory<AFSocketAddress>- Parameters:
addr- The address to connect to.- Returns:
- The socket instance.
- Throws:
IOException- on error.
-