NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.stack
Class IOHandler

java.lang.Object
  extended by gov.nist.javax.sip.stack.IOHandler

public class IOHandler
extends Object

Low level Input output to a socket. Caches TCP connections and takes care of re-connecting to the remote party if the other end drops the connection

Version:
1.2
Author:
M. Ranganathan

Method Summary
 void closeAll()
          Close all the cached connections.
 SocketAddress getLocalAddressForTcpDst(InetAddress dst, int dstPort, InetAddress localAddress, int localPort)
          Creates and binds, if necessary, a socket connected to the specified destination address and port and then returns its local address.
 SocketAddress getLocalAddressForTlsDst(InetAddress dst, int dstPort, InetAddress localAddress, TLSMessageChannel channel)
          Creates and binds, if necessary, a socket connected to the specified destination address and port and then returns its local address.
 Socket sendBytes(InetAddress senderAddress, InetAddress receiverAddress, int contactPort, String transport, byte[] bytes, boolean isClient, MessageChannel messageChannel)
          Send an array of bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLocalAddressForTcpDst

public SocketAddress getLocalAddressForTcpDst(InetAddress dst,
                                              int dstPort,
                                              InetAddress localAddress,
                                              int localPort)
                                       throws IOException
Creates and binds, if necessary, a socket connected to the specified destination address and port and then returns its local address.

Parameters:
dst - the destination address that the socket would need to connect to.
dstPort - the port number that the connection would be established with.
localAddress - the address that we would like to bind on (null for the "any" address).
localPort - the port that we'd like our socket to bind to (0 for a random port).
Returns:
the SocketAddress that this handler would use when connecting to the specified destination address and port.
Throws:
IOException - if we fail binding the socket

getLocalAddressForTlsDst

public SocketAddress getLocalAddressForTlsDst(InetAddress dst,
                                              int dstPort,
                                              InetAddress localAddress,
                                              TLSMessageChannel channel)
                                       throws IOException
Creates and binds, if necessary, a socket connected to the specified destination address and port and then returns its local address.

Parameters:
dst - the destination address that the socket would need to connect to.
dstPort - the port number that the connection would be established with.
localAddress - the address that we would like to bind on (null for the "any" address).
channel - the message channel that will be servicing the socket
Returns:
the SocketAddress that this handler would use when connecting to the specified destination address and port.
Throws:
IOException - if we fail binding the socket

sendBytes

public Socket sendBytes(InetAddress senderAddress,
                        InetAddress receiverAddress,
                        int contactPort,
                        String transport,
                        byte[] bytes,
                        boolean isClient,
                        MessageChannel messageChannel)
                 throws IOException
Send an array of bytes.

Parameters:
receiverAddress - -- inet address
contactPort - -- port to connect to.
transport - -- tcp or udp.
isClient - -- retry to connect if the other end closed connection
Throws:
IOException - -- if there is an IO exception sending message.

closeAll

public void closeAll()
Close all the cached connections.


NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.