verinec.netsim.util.net.sockets.fsm
Class FSMSocketImpl

java.lang.Object
  extended by java.net.SocketImpl
      extended by verinec.netsim.util.net.sockets.fsm.FSMSocketImpl
All Implemented Interfaces:
SocketOptions
Direct Known Subclasses:
SocketImplClosed, SocketImplCloseWait, SocketImplClosing, SocketImplEstablished, SocketImplFinWait1, SocketImplFinWait2, SocketImplLastAck, SocketImplListen, SocketImplSynRecieved, SocketImplSynSend, SocketImplTimedWait

public abstract class FSMSocketImpl
extends SocketImpl

The Finite State Machine for SocketImplementations. It acts as a wrapper that makes the protected methods visible

Version:
$Revision: 235 $
Author:
Dominik Jungo

Field Summary
protected  Logger jlogger
          this classes logger
protected  SocketImpl parent
          the socketImpl, which forwards it's work to this state socketImpl
 
Fields inherited from class java.net.SocketImpl
address, fd, localport, port
 
Fields inherited from interface java.net.SocketOptions
IP_MULTICAST_IF, IP_MULTICAST_IF2, IP_MULTICAST_LOOP, IP_TOS, SO_BINDADDR, SO_BROADCAST, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY
 
Constructor Summary
private FSMSocketImpl()
          Creates a new Finite State Machine for SocketImplementations
  FSMSocketImpl(SocketImpl parent)
          Creates a new Finite State Machine for SocketImplementations
 
Method Summary
protected  void create(boolean stream)
           
 void faccept(SocketImpl s)
           
 int favailable()
           
 void fbind(InetAddress host, int port)
           
 void fclose()
           
 void fconnect(InetAddress address, int port)
           
 void fconnect(SocketAddress address, int timeout)
           
 void fconnect(String host, int port)
           
 void fcreate(boolean stream)
           
 InputStream fgetInputStream()
           
 OutputStream fgetOutputStream()
           
 void fsendUrgentData(int data)
           
 Object getOption(int optID)
           
 void listen(int backlog)
           
abstract  void proccessUp(Packet packet)
          Proccesses an incoming packet
 void setBacklog(int backlog)
          Sets the number of accpeting connections
 void setOption(int optID, Object value)
           
 
Methods inherited from class java.net.SocketImpl
accept, available, bind, close, connect, connect, connect, getFileDescriptor, getInetAddress, getInputStream, getLocalPort, getOutputStream, getPort, sendUrgentData, setPerformancePreferences, shutdownInput, shutdownOutput, supportsUrgentData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected SocketImpl parent
the socketImpl, which forwards it's work to this state socketImpl


jlogger

protected Logger jlogger
this classes logger

Constructor Detail

FSMSocketImpl

public FSMSocketImpl(SocketImpl parent)
Creates a new Finite State Machine for SocketImplementations

Parameters:
parent - The SocketImpl

FSMSocketImpl

private FSMSocketImpl()
Creates a new Finite State Machine for SocketImplementations

Method Detail

proccessUp

public abstract void proccessUp(Packet packet)
Proccesses an incoming packet

Parameters:
packet - a packet to be proccessed

fclose

public void fclose()
            throws IOException
Throws:
IOException - if an I/O error occurs when closing this socket.
See Also:
SocketImpl.close()

favailable

public int favailable()
               throws IOException
Returns:
the number of bytes that can be read from this socket without blocking.
Throws:
IOException - if an I/O error occurs when determining the number of bytes available.
See Also:
SocketImpl.available()

listen

public void listen(int backlog)
            throws IOException
Specified by:
listen in class SocketImpl
Parameters:
backlog - the maximum length of the queue.
Throws:
IOException - if an I/O error occurs when creating the queue.
See Also:
SocketImpl.listen(int)

fsendUrgentData

public void fsendUrgentData(int data)
                     throws IOException
Parameters:
data - The byte of data to send
Throws:
IOException - if there is an error sending the data.
See Also:
SocketImpl.sendUrgentData(int)

fcreate

public void fcreate(boolean stream)
             throws IOException
Parameters:
stream - if true, create a stream socket; otherwise, create a datagram socket.
Throws:
IOException - if an I/O error occurs while creating the socket.
See Also:
SocketImpl.create(boolean)

fgetInputStream

public InputStream fgetInputStream()
                            throws IOException
Returns:
a stream for reading from this socket.
Throws:
IOException - if an I/O error occurs when creating the input stream.
See Also:
SocketImpl.getInputStream()

fgetOutputStream

public OutputStream fgetOutputStream()
                              throws IOException
Returns:
an output stream for writing to this socket.
Throws:
IOException - if an I/O error occurs when creating the output stream.
See Also:
SocketImpl.getOutputStream()

fconnect

public void fconnect(String host,
                     int port)
              throws IOException
Parameters:
host - the name of the remote host.
port - the port number.
Throws:
IOException - if an I/O error occurs when connecting to the remote host.
See Also:
SocketImpl.connect(java.lang.String, int)

fbind

public void fbind(InetAddress host,
                  int port)
           throws IOException
Parameters:
host - the IP address of the remote host.
port - the port number.
Throws:
IOException - if an I/O error occurs when binding this socket.
See Also:
SocketImpl.bind(java.net.InetAddress, int)

fconnect

public void fconnect(InetAddress address,
                     int port)
              throws IOException
Parameters:
address - the IP address of the remote host.
port - the port number.
Throws:
IOException - if an I/O error occurs when attempting a connection.
See Also:
SocketImpl.connect(java.net.InetAddress, int)

fconnect

public void fconnect(SocketAddress address,
                     int timeout)
              throws IOException
Parameters:
address - the Socket address of the remote host.
timeout - the timeout value, in milliseconds, or zero for no timeout.
Throws:
IOException - if an I/O error occurs when attempting a connection.
See Also:
SocketImpl.connect(java.net.SocketAddress, int)

faccept

public void faccept(SocketImpl s)
             throws IOException
Parameters:
s - the accepted connection.
Throws:
IOException - if an I/O error occurs when accepting the connection.
See Also:
SocketImpl.accept(java.net.SocketImpl)

getOption

public Object getOption(int optID)
                 throws SocketException
Parameters:
optID - an int identifying the option to fetch
Returns:
the value of the option
Throws:
SocketException - if the socket is closed
SocketException - if optID is unknown along the protocol stack (including the SocketImpl)
See Also:
SocketOptions.getOption(int)

setOption

public void setOption(int optID,
                      Object value)
               throws SocketException
Parameters:
optID - identifies the option
value - the parameter of the socket option
Throws:
SocketException - if the option is unrecognized, the socket is closed, or some low-level error occurred
See Also:
SocketOptions.setOption(int, java.lang.Object)

create

protected final void create(boolean stream)
                     throws IOException
Specified by:
create in class SocketImpl
Throws:
IOException
See Also:
SocketImpl.create(boolean)

setBacklog

public void setBacklog(int backlog)
Sets the number of accpeting connections

Parameters:
backlog - the number of accpeting connections

Copyright © 2005 Verinec, DIUF