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

Constructor Summary
protected IOHandler(SIPTransactionStack sipStack)
           
 
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.
protected  Socket getSocket(String key)
           
protected static String makeKey(InetAddress addr, int port)
           
protected static String makeKey(String addr, int port)
           
protected  void putSocket(String key, Socket sock)
           
protected  void removeSocket(String key)
           
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOHandler

protected IOHandler(SIPTransactionStack sipStack)
Method Detail

makeKey

protected static String makeKey(InetAddress addr,
                                int port)

makeKey

protected static String makeKey(String addr,
                                int port)

putSocket

protected void putSocket(String key,
                         Socket sock)

getSocket

protected Socket getSocket(String key)

removeSocket

protected void removeSocket(String key)

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.



Copyright © 2012. All Rights Reserved.