drastic.mCmdIF
Class SocketManager

java.lang.Object
  extended bydrastic.mCmdIF.SocketManager

public class SocketManager
extends java.lang.Object

Title: SocketManager

Description: Track sockets for reuse by multiple callers. Uses the SocketData class to manage/track each individual socket. Do not call directly, use MediaCmdIF which uses VVWNetCmdSender to communicate with this SocketManager.

Copyright: Copyright © 2004-2007

Company: Drastic Technologies Ltd.
523 The Queensway, Suite 102
Toronto, ON, M8Y 1J7
CANADA
416 255 5636
fax 255 8780
http://www.drastictech.com
engineering@drastictech.com

Version:
1.0
Author:
Dean Mitrovich
See Also:
SocketManager.SocketData, VVWNETCMDSENDER

Nested Class Summary
(package private)  class SocketManager.SocketData
          Title: SocketData
 
Field Summary
private  int m_timeOut
          Length of time in milliseconds to wait for a socket to connect.
(package private)  java.util.LinkedList SocketList
          The list of active sockets - NOTE: To maintain backward compatibility, do NOT parameterize this
 
Constructor Summary
SocketManager()
          SocketManager
 
Method Summary
(package private)  boolean Close(java.net.InetAddress inetAddress, int dwPort, boolean fAllInstances)
          Close the socket.
(package private)  SocketManager.SocketData Find(java.net.InetAddress inetAddress, int dwPort)
          Find a socket that has already been opened.
(package private)  java.io.InputStream GetInputStream(java.net.InetAddress inetAddress, int dwPort)
          Get the input stream.
(package private)  java.io.OutputStream GetOutputStream(java.net.InetAddress inetAddress, int dwPort)
          Get the output stream.
(package private)  boolean IsSocketConnected(java.net.InetAddress inetAddress, int dwPort)
          Returns whether we have a connection to this socket/port or not.
(package private)  boolean Open(java.net.InetAddress inetAddress, int dwPort)
          Open a socket.
(package private)  void setTimeout(java.net.InetAddress inetAddress, int dwPort, int nTimeOut)
          Changes the tpcip (SoTimeOut) timeout value for a socket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SocketList

java.util.LinkedList SocketList
The list of active sockets - NOTE: To maintain backward compatibility, do NOT parameterize this


m_timeOut

private int m_timeOut
Length of time in milliseconds to wait for a socket to connect.

Constructor Detail

SocketManager

public SocketManager()
SocketManager

Method Detail

Find

SocketManager.SocketData Find(java.net.InetAddress inetAddress,
                              int dwPort)
Find a socket that has already been opened. If there is a socket connected to inetAddress on that dwPort then return it. If not, return null.

Parameters:
inetAddress - InetAddress the target machine address or name
dwPort - int the port to connect on
Returns:
SocketData either null or the socket if it exists

Open

boolean Open(java.net.InetAddress inetAddress,
             int dwPort)
Open a socket. Either return an existing socket to that address and port, or create a new one and return that. New ones are added to the list.

Parameters:
inetAddress - InetAddress the ip address or name to attach to
dwPort - int the port to attach on
Returns:
boolean true if socket is open, else open failed

IsSocketConnected

boolean IsSocketConnected(java.net.InetAddress inetAddress,
                          int dwPort)
Returns whether we have a connection to this socket/port or not.

Parameters:
inetAddress - InetAddress the ip address or name to attach to
dwPort - int the port to attach on
Returns:
boolean true if we have an open socket for this name/port

setTimeout

void setTimeout(java.net.InetAddress inetAddress,
                int dwPort,
                int nTimeOut)
Changes the tpcip (SoTimeOut) timeout value for a socket.

Parameters:
inetAddress - InetAddress the ip address or name to attach to
dwPort - int the port to attach on
nTimeOut - int new time out value for the socket

Close

boolean Close(java.net.InetAddress inetAddress,
              int dwPort,
              boolean fAllInstances)
Close the socket. If fAllInstances is false, will close the reference, or if the reference is one it will close the actual socket. If fAllInstances is true, it will always close the actual socket.

Parameters:
inetAddress - InetAddress the ip address or name to close
dwPort - int the port to close
fAllInstances - boolean if true, close the actual socket. if false, reduce the reference count until it is 1, then close the actual socket
Returns:
boolean true if socket was closed or de-referenced

GetInputStream

java.io.InputStream GetInputStream(java.net.InetAddress inetAddress,
                                   int dwPort)
Get the input stream. Create and return an input stream for a socket.

Parameters:
inetAddress - InetAddress the ip address or name to attach to
dwPort - int the port to attach on
Returns:
InputStream input stream on the socket

GetOutputStream

java.io.OutputStream GetOutputStream(java.net.InetAddress inetAddress,
                                     int dwPort)
Get the output stream. Create and return an output stream for a socket.

Parameters:
inetAddress - InetAddress the ip address or name to attach to
dwPort - int the port to attach on
Returns:
OutputStream output stream on the socket