public final class TcpClient
extends java.lang.Object
implements java.io.Closeable
Socket.Socket(InetAddress, int).
Adds a data logging facility, and has idempotent getInputStream() and getOutputStream()
methods (as opposed to Socket).
Data logging is enabled by setting the level of logger de.unkrig.commons.net.TcpClient to Level.FINEST or higher.
TcpClient(InetAddress, int)| Constructor and Description |
|---|
TcpClient(java.net.InetAddress address,
int port)
Connects to the given
address and port. |
TcpClient(java.lang.String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.io.InputStream |
getInputStream() |
java.io.OutputStream |
getOutputStream() |
java.net.SocketAddress |
getRemoteSocketAddress() |
public TcpClient(java.lang.String host,
int port)
throws java.io.IOException
java.io.IOExceptionTcpClient(InetAddress, int)public TcpClient(java.net.InetAddress address,
int port)
throws java.io.IOException
address and port. Data can be sent to the remote server through the
OutputStream returned by getOutputStream(), and data can be read from the remote server
through the InputStream returned by getInputStream().java.io.IOExceptionpublic java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.net.SocketAddress getRemoteSocketAddress()