Module org.newsclub.net.unix
Package org.newsclub.net.unix
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 org.newsclub.net.unix.AFSocketFactory
AFSocketFactory.FixedAddressSocketFactory
-
Constructor Summary
ConstructorDescriptionFixedAddressSocketFactory
(SocketAddress address) Creates aAFSocketFactory.FixedAddressSocketFactory
. -
Method Summary
Modifier and TypeMethodDescriptionaddressFromHost
(String host, int port) Translates a "host" string (and port) to anAFSocketAddress
.protected Socket
connectTo
(AFSocketAddress addr) Creates a newAFSocket
, connected to the given address.boolean
isHostnameSupported
(String host) Checks whether the given hostname is supported by this socket factory.Methods inherited from class org.newsclub.net.unix.AFSocketFactory
createSocket, createSocket, createSocket, createSocket, isInetAddressSupported
Methods inherited from class javax.net.SocketFactory
getDefault
-
Constructor Details
-
FixedAddressSocketFactory
Creates aAFSocketFactory.FixedAddressSocketFactory
.- Parameters:
address
- The address to use for all connections.
-
-
Method Details
-
isHostnameSupported
Description copied from interface:AFSocketAddressFromHostname
Checks 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:
true
if supported.
-
addressFromHost
Description copied from interface:AFSocketAddressFromHostname
Translates 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:
createSocket
in classAFSocketFactory<AFSocketAddress>
- Throws:
SocketException
-
connectTo
Description copied from class:AFSocketFactory
Creates a newAFSocket
, connected to the given address.- Specified by:
connectTo
in classAFSocketFactory<AFSocketAddress>
- Parameters:
addr
- The address to connect to.- Returns:
- The socket instance.
- Throws:
IOException
- on error.
-