org.avineas.io.tcp
public class SocketChannel extends java.lang.Object
| Constructor and Description |
|---|
SocketChannel(java.lang.String host,
int port)
Create a socket to a specific remote TCP port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
int |
read(byte[] data,
int offset,
long timeout)
Read a packet or byte array from the channel, filling up either the data buffer or
the information as present in the packet.
|
java.lang.String |
toString() |
int |
write(byte[] data,
int length)
Write a packet or number of bytes via the channel.
|
public SocketChannel(java.lang.String host,
int port)
host - The host name to connect toport - The port at the remote host to connect topublic int read(byte[] data,
int offset,
long timeout)
ReadChannelread in interface ReadChanneldata - The byte buffer to read intooffset - The offset in the buffer to start readingtimeout - The timeout to wait for the first byte of data to become available, in ms.
If a value <= 0 is passed, no waiting is done at allpublic int write(byte[] data,
int length)
WriteChannelwrite in interface WriteChanneldata - The data to writelength - The length to write@PreDestroy public void close()
close in interface java.io.Closeablepublic java.lang.String toString()
toString in class java.lang.Object