jist.swans.trans
Interface SocketInterface.TcpSocketInterface

All Superinterfaces:
JistAPI.Proxiable, JistAPI.Timeless, SocketInterface
All Known Implementing Classes:
TcpSocket
Enclosing interface:
SocketInterface

public static interface SocketInterface.TcpSocketInterface
extends SocketInterface

Defines the interface for TcpSocket specific implementation.


Nested Class Summary
 
Nested classes/interfaces inherited from interface jist.swans.trans.SocketInterface
SocketInterface.TcpServerSocketInterface, SocketInterface.TcpSocketInterface
 
Method Summary
 void connect(java.net.SocketAddress endpoint)
          Connects this socket to the server.
 void connect(java.net.SocketAddress endpoint, int timeout)
          Connects this socket to the server with a specified timeout value.
 void constructPackets()
          Creates packets to be sent based on the receiver's advertised window (managing flow control).
 byte[] getBytesFromSocket(int length)
          This method is called by the input stream to retrieve data from the transport layer.
 java.nio.channels.SocketChannel getChannel()
          Returns the unique SocketChannel object associated with this socket, if any.
 InputStream getInputStream()
          Returns an input stream for this socket.
 boolean getKeepAlive()
          Tests if SO_KEEPALIVE is enabled.
 java.net.InetAddress getLocalAddress()
          Gets the local address to which the socket is bound.
 boolean getOOBInline()
          Tests if OOBINLINE is enabled.
 OutputStream getOutputStream()
          Returns an output stream for this socket.
 int getPort()
          Returns the remote port to which this socket is connected.
 java.net.SocketAddress getRemoteSocketAddress()
          Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
 int getSendBufferSize()
          Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
 int getSoLinger()
          Returns setting for SO_LINGER.
 boolean getTcpNoDelay()
          Tests if TCP_NODELAY is enabled.
 int getTrafficClass()
          Gets traffic class or type-of-service in the IP header for packets sent from this Socket.
 boolean isConnected()
          Returns the connection state of the socket.
 boolean isInputShutdown()
          Returns wether the read-half of the socket connection is closed.
 boolean isOutputShutdown()
          Returns wether the write-half of the socket connection is closed.
 void persistTimerTimeout(int timerId, int seqNum)
          Execution when persist timer times out (sending probe message).
 int queueBytes(byte[] data)
          This method is called to send bytes to the other side.
 void resetTimerTimeout(int timerId)
          Execution when reset timer times out (closing the socket).
 void retransmitTimerTimeout(int seqNum, long time)
          Attempt to retransmit because the timer times out.
 void sendUrgentData(int data)
          Send one byte of urgent data on the socket.
 void setKeepAlive(boolean on)
          Enable/disable SO_KEEPALIVE.
 void setOOBInline(boolean on)
          Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.
 void setSendBufferSize(int size)
          Sets the SO_SNDBUF option to the specified value for this Socket.
 void setSoLinger(boolean on, int linger)
          Enable/disable SO_LINGER with the specified linger time in seconds.
 void setTcpNoDelay(boolean on)
          Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
 void setTrafficClass(int tc)
          Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.
 void shutdownInput()
          Places the input stream for this socket at "end of stream".
 void shutdownOutput()
          Disables the output stream for this socket.
 void startPersistTimer(int seqNum)
          Methods for persist timer (sender sending packets to probe receiver window).
 void startResetTimer()
          Methods for reset timer (this timer is used when establishing or closing connection --> If no reply is received, connection is reset).
 void startRetransmitTimer(int seqNum, long time)
          Schedule a retransmission for a message.
 void startTimeWaitTimer()
          Methods for timer during TIME_WAIT state.
 void timeWaitTimerTimeout()
          Execution when time wait timer times out (closing the socket).
 
Methods inherited from interface jist.swans.trans.SocketInterface
_jistPostInit, bind, checkPacketandState, close, getInetAddress, getLocalPort, getLocalSocketAddress, getReceiveBufferSize, getReuseAddress, getSoTimeout, isBound, isClosed, setReceiveBufferSize, setReuseAddress, setSoTimeout, setTcpEntity, toString
 

Method Detail

connect

void connect(java.net.SocketAddress endpoint)
             throws JistAPI.Continuation
Connects this socket to the server.

Parameters:
endpoint - the SocketAddress
Throws:
JistAPI.Continuation - never; blocking event.

connect

void connect(java.net.SocketAddress endpoint,
             int timeout)
             throws JistAPI.Continuation
Connects this socket to the server with a specified timeout value.

Parameters:
endpoint - the SocketAddress
timeout - the timeout value to be used in milliseconds
Throws:
JistAPI.Continuation - never; blocking event.

getChannel

java.nio.channels.SocketChannel getChannel()
                                           throws JistAPI.Continuation
Returns the unique SocketChannel object associated with this socket, if any.

Returns:
the socket channel associated with this socket, or null if this socket was not created for a channel
Throws:
JistAPI.Continuation - never; blocking event.

getInputStream

InputStream getInputStream()
                           throws JistAPI.Continuation
Returns an input stream for this socket.

Returns:
an input stream for reading bytes from this socket.
Throws:
JistAPI.Continuation - never; blocking event.

getKeepAlive

boolean getKeepAlive()
                     throws JistAPI.Continuation
Tests if SO_KEEPALIVE is enabled.

Returns:
a boolean indicating whether or not SO_KEEPALIVE is enabled.
Throws:
JistAPI.Continuation - never; blocking event.

getLocalAddress

java.net.InetAddress getLocalAddress()
                                     throws JistAPI.Continuation
Gets the local address to which the socket is bound.

Returns:
the local address to which the socket is bound or InetAddress.anyLocalAddress() if the socket is not bound yet.
Throws:
JistAPI.Continuation - never; blocking event.

getOOBInline

boolean getOOBInline()
                     throws JistAPI.Continuation
Tests if OOBINLINE is enabled.

Returns:
a boolean indicating whether or not OOBINLINE is enabled.
Throws:
JistAPI.Continuation - never; blocking event.

getOutputStream

OutputStream getOutputStream()
                             throws JistAPI.Continuation
Returns an output stream for this socket.

Returns:
an output stream for writing bytes to this socket.
Throws:
JistAPI.Continuation - never; blocking event.

getPort

int getPort()
            throws JistAPI.Continuation
Returns the remote port to which this socket is connected.

Returns:
the remote port number to which this socket is connected, or 0 if the socket is not connected yet.
Throws:
JistAPI.Continuation - never; blocking event.

getRemoteSocketAddress

java.net.SocketAddress getRemoteSocketAddress()
                                              throws JistAPI.Continuation
Returns the address of the endpoint this socket is connected to, or null if it is unconnected.

Returns:
a SocketAddress representing the local endpoint of this socket, or null if it is not bound yet.
Throws:
JistAPI.Continuation - never; blocking event.

getSendBufferSize

int getSendBufferSize()
                      throws JistAPI.Continuation
Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.

Returns:
the value of the SO_SNDBUF option for this Socket.
Throws:
JistAPI.Continuation - never; blocking event.

getSoLinger

int getSoLinger()
                throws JistAPI.Continuation
Returns setting for SO_LINGER.

Returns:
the setting for SO_LINGER.
Throws:
JistAPI.Continuation - never; blocking event.

getTcpNoDelay

boolean getTcpNoDelay()
                      throws JistAPI.Continuation
Tests if TCP_NODELAY is enabled.

Returns:
a boolean indicating whether or not TCP_NODELAY is enabled.
Throws:
JistAPI.Continuation - never; blocking event.

getTrafficClass

int getTrafficClass()
                    throws JistAPI.Continuation
Gets traffic class or type-of-service in the IP header for packets sent from this Socket.

Returns:
the traffic class or type-of-service already set
Throws:
JistAPI.Continuation - never; blocking event.

isConnected

boolean isConnected()
                    throws JistAPI.Continuation
Returns the connection state of the socket.

Returns:
true if the socket successfuly connected to a server
Throws:
JistAPI.Continuation - never; blocking event.

isInputShutdown

boolean isInputShutdown()
                        throws JistAPI.Continuation
Returns wether the read-half of the socket connection is closed.

Returns:
true if the input of the socket has been shutdown
Throws:
JistAPI.Continuation - never; blocking event.

isOutputShutdown

boolean isOutputShutdown()
                         throws JistAPI.Continuation
Returns wether the write-half of the socket connection is closed.

Returns:
true if the output of the socket has been shutdown
Throws:
JistAPI.Continuation - never; blocking event.

sendUrgentData

void sendUrgentData(int data)
Send one byte of urgent data on the socket.

Parameters:
data - The byte of data to send

setKeepAlive

void setKeepAlive(boolean on)
Enable/disable SO_KEEPALIVE.

Parameters:
on - whether or not to have socket keep alive turned on

setOOBInline

void setOOBInline(boolean on)
Enable/disable OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.

Parameters:
on - true to enable OOBINLINE, false to disable.

setSendBufferSize

void setSendBufferSize(int size)
Sets the SO_SNDBUF option to the specified value for this Socket.

Parameters:
size - the size to which to set the send buffer size. This value must be greater than 0.

setSoLinger

void setSoLinger(boolean on,
                 int linger)
Enable/disable SO_LINGER with the specified linger time in seconds.

Parameters:
on - whether or not to linger on.
linger - how long to linger for, if on is true.

setTcpNoDelay

void setTcpNoDelay(boolean on)
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).

Parameters:
on - true to enable TCP_NODELAY, false to disable.

setTrafficClass

void setTrafficClass(int tc)
Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.

Parameters:
tc - an int value for the bitset.

shutdownInput

void shutdownInput()
                   throws JistAPI.Continuation,
                          java.io.IOException
Places the input stream for this socket at "end of stream".

Throws:
JistAPI.Continuation - never; blocking event.
java.io.IOException - if an I/O error occurs when shutting down this socket.

shutdownOutput

void shutdownOutput()
                    throws JistAPI.Continuation,
                           java.io.IOException
Disables the output stream for this socket.

Throws:
JistAPI.Continuation - never; blocking event.
java.io.IOException - if an I/O error occurs when shutting down this socket.

queueBytes

int queueBytes(byte[] data)
               throws JistAPI.Continuation
This method is called to send bytes to the other side. What this method does is storing the bytes in the send buffer and then call sendPackets method to send the bytes.

Parameters:
data - bytes to be stored in the send buffer
Returns:
the number of bytes actually stored
Throws:
JistAPI.Continuation - never; blocking event.

getBytesFromSocket

byte[] getBytesFromSocket(int length)
                          throws JistAPI.Continuation
This method is called by the input stream to retrieve data from the transport layer.

Parameters:
length - number of bytes to retrieve
Returns:
byte array containing data from socket
Throws:
JistAPI.Continuation - never; blocking event.

constructPackets

void constructPackets()
Creates packets to be sent based on the receiver's advertised window (managing flow control).


startRetransmitTimer

void startRetransmitTimer(int seqNum,
                          long time)
Schedule a retransmission for a message.

Parameters:
seqNum - sequence number of message to retransmit
time - wait time before attempting to retransmit

retransmitTimerTimeout

void retransmitTimerTimeout(int seqNum,
                            long time)
Attempt to retransmit because the timer times out.

Parameters:
seqNum - sequence number of message to retransmit
time - wait time before attempting to retransmit

startPersistTimer

void startPersistTimer(int seqNum)
Methods for persist timer (sender sending packets to probe receiver window).

Parameters:
seqNum - number of the probe message

persistTimerTimeout

void persistTimerTimeout(int timerId,
                         int seqNum)
Execution when persist timer times out (sending probe message).

Parameters:
timerId - ID of the persist timer
seqNum - number of the probe message

startResetTimer

void startResetTimer()
Methods for reset timer (this timer is used when establishing or closing connection --> If no reply is received, connection is reset).


resetTimerTimeout

void resetTimerTimeout(int timerId)
Execution when reset timer times out (closing the socket).

Parameters:
timerId - ID of the reset timer

startTimeWaitTimer

void startTimeWaitTimer()
Methods for timer during TIME_WAIT state.


timeWaitTimerTimeout

void timeWaitTimerTimeout()
Execution when time wait timer times out (closing the socket).