java.lang.Object | +--org.apache.commons.net.SocketClientKnown Direct Subclasses:
SocketFactory
static String | The end of line character sequence used by most IETF protocols. |
int | The default port the client should connect to. |
InputStream | The socket's InputStream. |
boolean | A status variable indicating if the client's socket is currently open. |
OutputStream | The socket's OutputStream. |
The socket's SocketFactory. | |
Socket | The socket used for the connection. |
int | The timeout to use after opening a socket. |
Default constructor for SocketClient. |
void | Because there are so many connect() methods, the _connectAction_() method is provided as a means of performing some action immediately after establishing a connection, rather than reimplementing all of the connect() methods. |
void | connect(InetAddress host, int port) Opens a Socket connected to a remote host at the specified port and originating from the current host at a system assigned port. |
void | connect(String hostname, int port) Opens a Socket connected to a remote host at the specified port and originating from the current host at a system assigned port. |
void | connect(InetAddress host, int port, InetAddress localAddr, int localPort) Opens a Socket connected to a remote host at the specified port and originating from the specified local address and port. |
void | connect(String hostname, int port, InetAddress localAddr, int localPort) Opens a Socket connected to a remote host at the specified port and originating from the specified local address and port. |
void | connect(InetAddress host) Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port. |
void | connect(String hostname) Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port. |
void | Disconnects the socket connection. |
int | Returns the current value of the default port (stored in _defaultPort_ ). |
int | Returns the default timeout in milliseconds that is used when opening a socket. |
InetAddress | Returns the local address to which the client's socket is bound. |
int | Returns the port number of the open socket on the local host used for the connection. |
InetAddress | |
int | Returns the port number of the remote host to which the client is connected. |
int | Returns the current SO_LINGER timeout of the currently opened socket. |
int | Returns the timeout in milliseconds of the currently opened socket. |
boolean | Returns true if Nagle's algorithm is enabled on the currently opened socket. |
boolean | Returns true if the client is currently connected to a server. |
void | setDefaultPort(int port) Sets the default port the SocketClient should connect to when a port is not specified. |
void | setDefaultTimeout(int timeout) Set the default timeout in milliseconds to use when opening a socket. |
void | setSoLinger(boolean on, int val) Sets the SO_LINGER timeout on the currently opened socket. |
void | setSoTimeout(int timeout) Set the timeout in milliseconds of a currently open connection. |
void | setSocketFactory(SocketFactory factory) Sets the SocketFactory used by the SocketClient to open socket connections. |
void | setTcpNoDelay(boolean on) Enables or disables the Nagle's algorithm (TCP_NODELAY) on the currently opened socket. |
boolean | verifyRemote(Socket socket) Verifies that the remote end of the given socket is connected to the the same host that the SocketClient is currently connected to. |
public static final String NETASCII_EOL
protected int _defaultPort_
protected InputStream _input_
protected boolean _isConnected_
protected OutputStream _output_
protected SocketFactory _socketFactory_
protected Socket _socket_
protected int _timeout_
public SocketClient()
protected void _connectAction_()
super._connectAction_() first to ensure the
initialization of the aforementioned protected variables.
public void connect(InetAddress host)
- If the socket timeout could not be set. - If the socket could not be opened.public void connect(InetAddress host, int port)
- If the socket timeout could not be set. - If the socket could not be opened.public void connect(InetAddress host, int port, InetAddress localAddr, int localPort)
- If the socket timeout could not be set. - If the socket could not be opened.public void connect(String hostname)
- If the socket timeout could not be set. - If the socket could not be opened. - If the hostname cannot be resolved.public void connect(String hostname, int port)
- If the socket timeout could not be set. - If the socket could not be opened. - If the hostname cannot be resolved.public void connect(String hostname, int port, InetAddress localAddr, int localPort)
- If the socket timeout could not be set. - If the socket could not be opened. - If the hostname cannot be resolved.public void disconnect()
- If there is an error closing the socket.public int getDefaultPort()
public int getDefaultTimeout()
public InetAddress getLocalAddress()
public int getLocalPort()
public InetAddress getRemoteAddress()
public int getRemotePort()
public int getSoLinger()
- If the operation fails.public int getSoTimeout()
- If the operation fails.public boolean getTcpNoDelay()
- If the operation fails.public boolean isConnected()
public void setDefaultPort(int port)
public void setDefaultTimeout(int timeout)
public void setSoLinger(boolean on, int val)
- If the operation fails.public void setSoTimeout(int timeout)
- If the operation fails.public void setSocketFactory(SocketFactory factory)
public void setTcpNoDelay(boolean on)
- If the operation fails.public boolean verifyRemote(Socket socket)