Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.act365.net.tcp
Class TCPJSocketImpl  view TCPJSocketImpl download TCPJSocketImpl.java

java.lang.Object
  extended byjava.net.SocketImpl
      extended bycom.act365.net.tcp.TCPJSocketImpl
All Implemented Interfaces:
java.util.EventListener, java.beans.PropertyChangeListener, java.net.SocketOptions

class TCPJSocketImpl
extends java.net.SocketImpl
implements java.beans.PropertyChangeListener

Implements the TCPJ protocol, which is a clone of TCP that would typically be used with a non-standard IP protocol setting.


Field Summary
(package private)  int acknowledgedseqnum
           
(package private)  TCPAcknowledger acknowledger
           
(package private) static double alpha
           
(package private) static double beta
           
(package private) static boolean closeserver
           
(package private) static boolean debug
           
(package private)  int destseqnum
           
(package private)  int destwindowsize
           
(package private) static boolean implementackdelay
           
(package private) static boolean includeipheader
           
(package private)  java.net.InetAddress localhost
           
(package private)  int localseqnum
           
(package private) static int maxEphemeralPort
           
(package private) static int maxwindowsize
           
(package private) static int minEphemeralPort
           
(package private) static boolean modelpacketloss
           
(package private) static long msltimeout
           
(package private)  TCPMSLTimer msltimer
           
(package private) static int nextEphemeralPort
           
(package private) static double packetloss
           
(package private)  int previousstate
           
(package private) static int protocol
           
(package private)  java.util.Random random
           
(package private)  byte[] readbuffer
           
(package private)  int readcount
           
(package private)  int readoffset
           
(package private)  long receivetime
           
(package private)  long rto
           
(package private)  long rtt
           
(package private)  long sendtime
           
(package private)  java.net.DatagramSocket socket
           
(package private)  int state
           
(package private) static int transmissionlimit
           
(package private)  int windowsize
           
 
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
TCPJSocketImpl()
          Default constructor
 
Method Summary
 void accept(java.net.SocketImpl newSocket)
          Accepts a server connection.
 void acknowledge()
          Acknowledges a received TCP message.
(package private)  void activeOpen(java.net.InetAddress address, short port)
           
 int available()
          Returns the number of bytes available to be read without polling.
 void bind(java.net.InetAddress inetAddress, int port)
          Binds a socket to the given address and port.
 void close()
          Closes a connection.
 void connect(java.net.InetAddress dst, int remotePort)
          Connects to a remote address.
 void connect(java.net.SocketAddress address, int timeout)
          Connects to a socket address.
 void connect(java.lang.String hostname, int port)
          Connects to a remote address.
 void create(boolean stream)
          Creates a new TCPJ socket.
 java.io.InputStream getInputStream()
          Gets an input stream to read.
 java.lang.Object getOption(int optID)
          Gets a TCP option.
 java.io.OutputStream getOutputStream()
          Gets an output stream to write.
 void listen(int backlog)
          Sets a server to listen for a client connection.
(package private)  void passiveOpen()
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
          Called by TCPJListener if a message is received.
 int read(byte[] buffer, int offset, int count)
          Reads a buffer.
(package private)  void receive(TCPMessage message)
          Handles an received TCPMessage
(package private)  void resetSocket()
          Resets a socket to its default values.
(package private)  void send(int flags)
          Sends a message with no data but doesn't await acknowledgement.
(package private)  void send(int flags, TCPOptions options, byte[] buffer, int offset, int count, boolean retransmission)
          Sends a TCP message to the destination but doesn't await acknowledgement.
(package private)  void sendAndAwaitACK(int flags)
          Sends a message with no data and awaits acknowledgement.
(package private)  void sendAndAwaitACK(int flags, TCPOptions options)
          Sends a message with no data but some options and awaits acknowledgement.
(package private)  void sendAndAwaitACK(int flags, TCPOptions options, byte[] buffer, int offset, int count)
          Sends a message and awaits acknowledgement.
 void sendUrgentData(int data)
          Urgent data is not supported.
 void setOption(int optID, java.lang.Object value)
          Sets a TCP option.
(package private)  void setState(int state)
           
(package private)  void tcpjClose()
           
(package private)  void timeWait()
           
(package private)  void transmit(int flags, TCPOptions options, byte[] buffer, int offset, int count, boolean retransmit)
          Transmits a TCP message to the destination.
(package private)  void updateRTO()
          Updates the Retransmission Timeout Value (RTO).
 void write(byte[] buffer, int offset, int count)
          Writes a buffer and awaits acknowledgement.
 
Methods inherited from class java.net.SocketImpl
getFileDescriptor, getInetAddress, getLocalPort, getPort, shutdownInput, shutdownOutput, supportsUrgentData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

msltimeout

static final long msltimeout
See Also:
Constant Field Values

transmissionlimit

static final int transmissionlimit
See Also:
Constant Field Values

maxwindowsize

static final int maxwindowsize
See Also:
Constant Field Values

minEphemeralPort

static final int minEphemeralPort
See Also:
Constant Field Values

maxEphemeralPort

static final int maxEphemeralPort
See Also:
Constant Field Values

protocol

static final int protocol

debug

static final boolean debug
See Also:
Constant Field Values

closeserver

static final boolean closeserver
See Also:
Constant Field Values

includeipheader

static final boolean includeipheader

implementackdelay

static final boolean implementackdelay
See Also:
Constant Field Values

modelpacketloss

static final boolean modelpacketloss
See Also:
Constant Field Values

alpha

static final double alpha
See Also:
Constant Field Values

beta

static final double beta
See Also:
Constant Field Values

packetloss

static final double packetloss
See Also:
Constant Field Values

nextEphemeralPort

static int nextEphemeralPort

socket

java.net.DatagramSocket socket

localhost

java.net.InetAddress localhost

state

int state

previousstate

int previousstate

localseqnum

int localseqnum

destseqnum

int destseqnum

acknowledgedseqnum

int acknowledgedseqnum

windowsize

int windowsize

destwindowsize

int destwindowsize

readoffset

int readoffset

readcount

int readcount

rto

long rto

rtt

long rtt

sendtime

long sendtime

receivetime

long receivetime

readbuffer

byte[] readbuffer

acknowledger

TCPAcknowledger acknowledger

msltimer

TCPMSLTimer msltimer

random

java.util.Random random
Constructor Detail

TCPJSocketImpl

public TCPJSocketImpl()
               throws java.net.SocketException
Default constructor

Method Detail

send

void send(int flags,
          TCPOptions options,
          byte[] buffer,
          int offset,
          int count,
          boolean retransmission)
    throws java.io.IOException
Sends a TCP message to the destination but doesn't await acknowledgement. Checks whether the receiver is ready to receive.


updateRTO

void updateRTO()
Updates the Retransmission Timeout Value (RTO).


sendAndAwaitACK

void sendAndAwaitACK(int flags,
                     TCPOptions options,
                     byte[] buffer,
                     int offset,
                     int count)
               throws java.io.IOException
Sends a message and awaits acknowledgement. Updates the estimate of the connection round-trip time.


send

void send(int flags)
    throws java.io.IOException
Sends a message with no data but doesn't await acknowledgement.


sendAndAwaitACK

void sendAndAwaitACK(int flags)
               throws java.io.IOException
Sends a message with no data and awaits acknowledgement.


sendAndAwaitACK

void sendAndAwaitACK(int flags,
                     TCPOptions options)
               throws java.io.IOException
Sends a message with no data but some options and awaits acknowledgement.


transmit

void transmit(int flags,
              TCPOptions options,
              byte[] buffer,
              int offset,
              int count,
              boolean retransmit)
        throws java.io.IOException
Transmits a TCP message to the destination. No check is made beforehand to see whether the receiver is ready to receive.


acknowledge

public void acknowledge()
                 throws java.io.IOException
Acknowledges a received TCP message.


resetSocket

void resetSocket()
Resets a socket to its default values.


receive

void receive(TCPMessage message)
       throws java.io.IOException
Handles an received TCPMessage


activeOpen

void activeOpen(java.net.InetAddress address,
                short port)
          throws java.io.IOException

passiveOpen

void passiveOpen()
           throws java.io.IOException

tcpjClose

void tcpjClose()
         throws java.io.IOException

setState

void setState(int state)

timeWait

void timeWait()
        throws java.io.IOException

write

public void write(byte[] buffer,
                  int offset,
                  int count)
           throws java.io.IOException
Writes a buffer and awaits acknowledgement.


read

public int read(byte[] buffer,
                int offset,
                int count)
         throws java.io.IOException
Reads a buffer.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Called by TCPJListener if a message is received.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

create

public void create(boolean stream)
            throws java.io.IOException
Creates a new TCPJ socket.


bind

public void bind(java.net.InetAddress inetAddress,
                 int port)
          throws java.io.IOException
Binds a socket to the given address and port.


connect

public void connect(java.lang.String hostname,
                    int port)
             throws java.io.IOException
Connects to a remote address.


connect

public void connect(java.net.SocketAddress address,
                    int timeout)
             throws java.io.IOException
Connects to a socket address.


connect

public void connect(java.net.InetAddress dst,
                    int remotePort)
             throws java.io.IOException
Connects to a remote address.


accept

public void accept(java.net.SocketImpl newSocket)
Accepts a server connection.


close

public void close()
           throws java.io.IOException
Closes a connection.


listen

public void listen(int backlog)
            throws java.io.IOException
Sets a server to listen for a client connection. Note that the backlog argument is ignored - currently, TCPJ cannot stack connection requests.


setOption

public void setOption(int optID,
                      java.lang.Object value)
               throws java.net.SocketException
Sets a TCP option.

Specified by:
setOption in interface java.net.SocketOptions

getOption

public java.lang.Object getOption(int optID)
                           throws java.net.SocketException
Gets a TCP option.

Specified by:
getOption in interface java.net.SocketOptions

available

public int available()
Returns the number of bytes available to be read without polling.


getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Gets an input stream to read.


getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Gets an output stream to write.


sendUrgentData

public void sendUrgentData(int data)
                    throws java.io.IOException
Urgent data is not supported.