public class TcpLayer extends java.lang.Object implements TransportLayer
Constructor and Description |
---|
TcpLayer(TcpSettings settings) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Will close the TCP connection to the server if its still open and free any resources of this connection.
|
java.io.DataInputStream |
getInputStream()
Returns the input stream for this stream accessor.
|
java.io.DataOutputStream |
getOutpuStream()
Returns the output stream for this stream accessor.
|
boolean |
isClosed()
Status of the connection/transport layer.
|
void |
open()
Opens the physical layer.
|
void |
setTimeout(int timeout)
Enable/disable TIMEOUT with the specified timeout, in milliseconds.
|
public TcpLayer(TcpSettings settings)
public void setTimeout(int timeout) throws java.io.IOException
StreamAccessor
InputStream
m associated with this StreamAcessor will block for only this amount of
time. If the timeout expires, a java.net.SocketTimeoutException is raised, though the Socket is still valid. The
option must be enabled prior to entering the blocking operation to have effect. The timeout must be
> 0
. A timeout of zero is interpreted as an infinite timeout.setTimeout
in interface StreamAccessor
timeout
- the specified timeout, in milliseconds.java.io.IOException
- if there is an error in the underlying protocol, such as a TCP error.public java.io.DataInputStream getInputStream()
StreamAccessor
getInputStream
in interface StreamAccessor
public boolean isClosed()
TransportLayer
isClosed
in interface TransportLayer
true
if the connection is closes false
otherwhise.public java.io.DataOutputStream getOutpuStream()
StreamAccessor
getOutpuStream
in interface StreamAccessor
public void open() throws java.io.IOException
TransportLayer
open
in interface TransportLayer
java.io.IOException
- if an error occurred opening the stream.public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface StreamAccessor
java.io.IOException