Top Description Inners Fields Constructors Methods
org.newsclub.net.unix

public abstract Class AFSocketFactory<A extends AFSocketAddress>

extends SocketFactory
implements AFSocketAddressFromHostname<A extends AFSocketAddress>
Class Inheritance
All Implemented Interfaces
org.newsclub.net.unix.AFSocketAddressFromHostname
Known Direct Subclasses
org.newsclub.net.unix.AFSocketFactory.FixedAddressSocketFactory, org.newsclub.net.unix.AFUNIXSocketFactory, org.newsclub.net.unix.AFGenericSocketFactory
Type Parameters
<A>
The supported address type.
Imports
java.io.IOException, java.net.InetAddress, .Socket, .SocketAddress, .SocketException, java.util.Objects, javax.net.SocketFactory

The base for a SocketFactory that connects to UNIX sockets. Typically, the "hostname" is used as a reference to a socketFile on the file system. The actual mapping is left to the implementor.
See Also
AFUNIXSocketFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AFSocketFactory.FixedAddressSocketFactory

A socket factory that always connects to a fixed socket address, no matter what.

Field Summary

Modifier and TypeField and Description
private final Class<? extends AFSocketAddress>

Constructor Summary

AccessConstructor and Description
protected
AFSocketFactory(Class<? extends AFSocketAddress>
The AFSocketAddress subclass.
socketAddressClass
)

Creates a new socket factory instance.

Method Summary

Modifier and TypeMethod and Description
protected abstract Socket

Returns:

The socket instance.
connectTo
(A
The address to connect to.
addr
)

Creates a new AFSocket, connected to the given address.

private Socket
public abstract Socket
createSocket()

Overrides javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

public final Socket
createSocket(String
the server host name with which to connect, or null for the loopback address.
host
,
int
the server port
port
)

Implements abstract javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified remote host at the specified remote port.

public final Socket
createSocket(String
the server host name with which to connect, or null for the loopback address.
host
,
int
the server port
port
,
InetAddress
the local address the socket is bound to
localHost
,
int
the local port the socket is bound to
localPort
)

Implements abstract javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified remote host on the specified remote port.

public final Socket
createSocket(InetAddress
the server host
address
,
int
the server port
port
)

Implements abstract javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified port number at the specified address.

public final Socket
createSocket(InetAddress
the server network address
address
,
int
the server port
port
,
InetAddress
the client network address
localAddress
,
int
the client port
localPort
)

Implements abstract javax.net.SocketFactory.createSocket.

Creates a socket and connect it to the specified remote address on the specified remote port.

protected final boolean

Returns:

true if supported.
isInetAddressSupported
(InetAddress
The address to check.
address
)

Checks whether the given InetAddress is supported by this socket factory.

Inherited from javax.net.SocketFactory:
getDefault

Field Detail

socketAddressClassback to summary
private final Class<? extends AFSocketAddress> socketAddressClass

Constructor Detail

AFSocketFactoryback to summary
protected AFSocketFactory(Class<? extends AFSocketAddress> socketAddressClass)

Creates a new socket factory instance.

Parameters
socketAddressClass:Class<? extends AFSocketAddress>

The AFSocketAddress subclass.

Method Detail

connectToback to summary
protected abstract Socket connectTo(A addr) throws IOException

Creates a new AFSocket, connected to the given address.

Parameters
addr:A

The address to connect to.

Returns:Socket

The socket instance.

Exceptions
IOException:
on error.
connectToback to summary
private Socket connectTo(SocketAddress addr) throws IOException
Annotations
@SuppressWarnings:unchecked
createSocketback to summary
public abstract Socket createSocket() throws SocketException

Overrides javax.net.SocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

Returns:Socket

the unconnected socket

Annotations
@Override
createSocketback to summary
public final Socket createSocket(String host, int port) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified remote host at the specified remote port. This socket is configured using the socket options established for this factory.

Parameters
host:String

the server host name with which to connect, or null for the loopback address.

port:int

the server port

Returns:Socket

the Socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the socket
createSocketback to summary
public final Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified remote host on the specified remote port. The socket will also be bound to the local address and port supplied. This socket is configured using the socket options established for this factory.

Parameters
host:String

the server host name with which to connect, or null for the loopback address.

port:int

the server port

localHost:InetAddress

the local address the socket is bound to

localPort:int

the local port the socket is bound to

Returns:Socket

the Socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the socket
createSocketback to summary
public final Socket createSocket(InetAddress address, int port) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates a socket and connects it to the specified port number at the specified address. This socket is configured using the socket options established for this factory.

Parameters
address:InetAddress

the server host

port:int

the server port

Returns:Socket

the Socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the socket
createSocketback to summary
public final Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException

Implements abstract javax.net.SocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates a socket and connect it to the specified remote address on the specified remote port. The socket will also be bound to the local address and port supplied. The socket is configured using the socket options established for this factory.

Parameters
address:InetAddress

the server network address

port:int

the server port

localAddress:InetAddress

the client network address

localPort:int

the client port

Returns:Socket

the Socket

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs when creating the socket
isInetAddressSupportedback to summary
protected final boolean isInetAddressSupported(InetAddress address)

Checks whether the given InetAddress is supported by this socket factory. If not, calls to createSocket will cause a SocketException. By default, this only checks the hostname part of the address via isHostnameSupported(String).

Parameters
address:InetAddress

The address to check.

Returns:boolean

true if supported.

org.newsclub.net.unix back to summary

public final Class AFSocketFactory.FixedAddressSocketFactory

extends AFSocketFactory<AFSocketAddress>
Class Inheritance

A socket factory that always connects to a fixed socket address, no matter what.

Field Summary

Modifier and TypeField and Description
private final SocketAddress

Constructor Summary

AccessConstructor and Description
public
FixedAddressSocketFactory(SocketAddress
The address to use for all connections.
address
)

Creates a FixedAddressSocketFactory.

Method Summary

Modifier and TypeMethod and Description
public SocketAddress
addressFromHost(String
The hostname
host
,
int
The port, or 0.
port
)

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

protected Socket
connectTo(AFSocketAddress
The address to connect to.
addr
)

Implements abstract org.newsclub.net.unix.AFSocketFactory.connectTo.

Creates a new AFSocket, connected to the given address.

public Socket
createSocket()

Implements abstract org.newsclub.net.unix.AFSocketFactory.createSocket.

Creates an unconnected socket.

public boolean
isHostnameSupported(String
The host to check.
host
)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory.

Inherited from org.newsclub.net.unix.AFSocketFactory:
createSocketcreateSocketcreateSocketcreateSocketisInetAddressSupported

Field Detail

forceAddrback to summary
private final SocketAddress forceAddr

Constructor Detail

FixedAddressSocketFactoryback to summary
public FixedAddressSocketFactory(SocketAddress address)

Creates a FixedAddressSocketFactory.

Parameters
address:SocketAddress

The address to use for all connections.

Method Detail

addressFromHostback to summary
public SocketAddress addressFromHost(String host, int port) throws SocketException

Implements org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.addressFromHost.

Translates a "host" string (and port) to an AFSocketAddress.

Parameters
host:String

The hostname

port:int

The port, or 0.

Returns:SocketAddress

The AFSocketAddress

Annotations
@Override
Exceptions
SocketException:
If there was a problem converting the hostname
connectToback to summary
protected Socket connectTo(AFSocketAddress addr) throws IOException

Implements abstract org.newsclub.net.unix.AFSocketFactory.connectTo.

Doc from org.newsclub.net.unix.AFSocketFactory.connectTo.

Creates a new AFSocket, connected to the given address.

Parameters
addr:AFSocketAddress

The address to connect to.

Returns:Socket

The socket instance.

Annotations
@Override
Exceptions
IOException:
on error.
createSocketback to summary
public Socket createSocket() throws SocketException

Implements abstract org.newsclub.net.unix.AFSocketFactory.createSocket.

Doc from javax.net.SocketFactory.createSocket.

Creates an unconnected socket.

Returns:Socket

the unconnected socket

Annotations
@Override
isHostnameSupportedback to summary
public boolean isHostnameSupported(String host)

Overrides default org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Doc from org.newsclub.net.unix.AFSocketAddressFromHostname.isHostnameSupported.

Checks whether the given hostname is supported by this socket factory. If not, calls to createSocket will cause a SocketException.

Parameters
host:String

The host to check.

Returns:boolean

true if supported.

Annotations
@Override