jist.swans.trans
Interface SocketInterface

All Superinterfaces:
JistAPI.Proxiable, JistAPI.Timeless
All Known Subinterfaces:
SocketInterface.TcpServerSocketInterface, SocketInterface.TcpSocketInterface
All Known Implementing Classes:
TcpServerSocket, TcpSocket

public interface SocketInterface
extends JistAPI.Proxiable

Defines the interface of all socket entity implementations.

Since:
SWANS1.0
Version:
$Id: SocketInterface.java,v 1.13 2004/04/06 16:07:51 barr Exp $
Author:
Kelwin Tamtoro <kt222@cs.cornell.edu>, Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
static interface SocketInterface.TcpServerSocketInterface
          Defines the interface for TcpServerSocket specific implementation.
static interface SocketInterface.TcpSocketInterface
          Defines the interface for TcpSocket specific implementation.
 
Method Summary
 void _jistPostInit()
          Post-constructor call.
 void bind(java.net.SocketAddress bindpoint)
          Binds the ServerSocket to a specific address (IP address and port number).
 void checkPacketandState(TransTcp.TcpMessage msg, NetAddress src)
          Check and process the incoming packet depending on current state of the socket.
 void close()
          Closes this socket.
 java.net.InetAddress getInetAddress()
          Returns the local address of this server socket/socket.
 int getLocalPort()
          Returns the port on which this socket is listening.
 java.net.SocketAddress getLocalSocketAddress()
          Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.
 int getReceiveBufferSize()
          Gets the value of the SO_RCVBUF option for this ServerSocket, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocket.
 boolean getReuseAddress()
          Tests if SO_REUSEADDR is enabled.
 int getSoTimeout()
          Retrieve setting for SO_TIMEOUT.
 boolean isBound()
          Returns the binding state of the ServerSocket.
 boolean isClosed()
          Returns the closed state of the ServerSocket.
 void setReceiveBufferSize(int size)
          Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocket.
 void setReuseAddress(boolean on)
          Enable/disable the SO_REUSEADDR socket option.
 void setSoTimeout(int timeout)
          Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
 void setTcpEntity(TransInterface.TransTcpInterface tcpEntity)
          Sets the reference to the network layer.
 java.lang.String toString()
          Returns the implementation address and implementation port of this socket as a String.
 

Method Detail

_jistPostInit

void _jistPostInit()
                   throws JistAPI.Continuation
Post-constructor call. Since constructors can not be blocking (JiST/Java limitation), we rewrite a regular socket constructor to two calls. This is the second one, and it can be blocking, because it is a regular method.

Throws:
JistAPI.Continuation - never; blocking event.

setTcpEntity

void setTcpEntity(TransInterface.TransTcpInterface tcpEntity)
Sets the reference to the network layer.

Parameters:
tcpEntity - entity reference to transport layer

bind

void bind(java.net.SocketAddress bindpoint)
          throws JistAPI.Continuation
Binds the ServerSocket to a specific address (IP address and port number).

Parameters:
bindpoint - The IP address & port number to bind to.
Throws:
JistAPI.Continuation - never; blocking event.

close

void close()
Closes this socket.


getInetAddress

java.net.InetAddress getInetAddress()
                                    throws JistAPI.Continuation
Returns the local address of this server socket/socket.

Returns:
the address to which this socket is bound, or null if the socket is unbound.
Throws:
JistAPI.Continuation - never; blocking event.

getLocalPort

int getLocalPort()
                 throws JistAPI.Continuation
Returns the port on which this socket is listening.

Returns:
the port number to which this socket is listening or -1 if the socket is not bound yet.
Throws:
JistAPI.Continuation - never; blocking event.

getLocalSocketAddress

java.net.SocketAddress getLocalSocketAddress()
                                             throws JistAPI.Continuation
Returns the address of the endpoint this socket is bound to, or null if it is not bound yet.

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

getReceiveBufferSize

int getReceiveBufferSize()
                         throws JistAPI.Continuation
Gets the value of the SO_RCVBUF option for this ServerSocket, that is the proposed buffer size that will be used for Sockets accepted from this ServerSocket.

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

getReuseAddress

boolean getReuseAddress()
                        throws JistAPI.Continuation
Tests if SO_REUSEADDR is enabled.

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

getSoTimeout

int getSoTimeout()
                 throws JistAPI.Continuation
Retrieve setting for SO_TIMEOUT.

Returns:
the SO_TIMEOUT value
Throws:
JistAPI.Continuation - never; blocking event.

isBound

boolean isBound()
                throws JistAPI.Continuation
Returns the binding state of the ServerSocket.

Returns:
true if the ServerSocket succesfuly bound to an address
Throws:
JistAPI.Continuation - never; blocking event.

isClosed

boolean isClosed()
                 throws JistAPI.Continuation
Returns the closed state of the ServerSocket.

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

setReceiveBufferSize

void setReceiveBufferSize(int size)
Sets a default proposed value for the SO_RCVBUF option for sockets accepted from this ServerSocket.

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

setReuseAddress

void setReuseAddress(boolean on)
Enable/disable the SO_REUSEADDR socket option.

Parameters:
on - whether to enable or disable the socket option

setSoTimeout

void setSoTimeout(int timeout)
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

Parameters:
timeout - the specified timeout, in milliseconds

toString

java.lang.String toString()
                          throws JistAPI.Continuation
Returns the implementation address and implementation port of this socket as a String.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this socket.
Throws:
JistAPI.Continuation - never; blocking event.

checkPacketandState

void checkPacketandState(TransTcp.TcpMessage msg,
                         NetAddress src)
Check and process the incoming packet depending on current state of the socket.

Parameters:
msg - the incoming TCP message
src - source of packet