sipxportlib  Version 3.3
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
OsSocket Class Referenceabstract

#include <OsSocket.h>

Inheritance diagram for OsSocket:
Inheritance graph
[legend]
Collaboration diagram for OsSocket:
Collaboration graph
[legend]

Public Types

enum  IpProtocolSocketType {
  UNKNOWN = -1, TCP = 0, UDP = 1, MULTICAST = 2,
  SSL_SOCKET = 3, CUSTOM = 4
}
 

Public Member Functions

virtual UtlContainableType getContainableType () const
 Determine whether or not the values in a containable are comparable. More...
 
 OsSocket ()
 
virtual ~OsSocket ()
 
virtual int write (const char *buffer, int bufferLength, const char *ipAddress, int port)
 
virtual int write (const char *buffer, int bufferLength)
 
virtual int write (const char *buffer, int bufferLength, long waitMilliseconds)
 param: buffer - The bytes to be written to the socket. param: bufferLength - The number of bytes contained in buffer. returns: The number of bytes actually written to the socket. returns:
Note: This does not necessarily mean that the bytes were returns: actually received on the other end. More...
 
virtual int read (char *buffer, int bufferLength)
 param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero, in which case it does not block. More...
 
virtual int read (char *buffer, int bufferLength, UtlString *ipAddress, int *port)
 param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. returns: The number of bytes actually read. More...
 
virtual int read (char *buffer, int bufferLength, struct in_addr *ipAddress, int *port)
 param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. param: ipAddress - The address of the socket that sent the bytes read. param: port - The port of the socket that sent the bytes read. returns: The number of bytes actually read. More...
 
virtual int read (char *buffer, int bufferLength, long waitMilliseconds)
 param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. param: ipAddress - The address of the socket that sent the bytes read. param: port - The port of the socket that sent the bytes read. returns: The number of bytes actually read. More...
 
virtual void close ()
 param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero in which case it does not block. More...
 
virtual void makeNonblocking ()
 
virtual void makeBlocking ()
 
virtual OsSocket::IpProtocolSocketType getIpProtocol () const =0
 
virtual UtlBoolean reconnect ()=0
 
virtual int getSocketDescriptor () const
 
virtual void getLocalHostIp (UtlString *localHostAddress) const
 
virtual const UtlStringgetLocalIp () const
 
virtual void setLocalIp (const UtlString &localIp)
 
virtual int getLocalHostPort () const
 
virtual void getRemoteHostName (UtlString *remoteHostName) const
 
virtual void getRemoteHostIp (struct in_addr *remoteHostAddress, int *remotePort=NULL)
 
virtual void getRemoteHostIp (UtlString *remoteHostAddress, int *remotePort=NULL)
 
virtual int getRemoteHostPort () const
 
virtual UtlBoolean isOk () const
 
virtual UtlBoolean isConnected () const
 
virtual UtlBoolean isReadyToReadEx (long waitMilliseconds, UtlBoolean &rSocketError) const
 
virtual UtlBoolean isReadyToRead (long waitMilliseconds=0) const
 
virtual UtlBoolean isReadyToWrite (long waitMilliseconds=0) const
 
- Public Member Functions inherited from UtlContainableAtomic
virtual unsigned hash () const
 Calculate a hash code for this object. More...
 
virtual int compareTo (UtlContainable const *) const
 Compare this object to another object. More...
 
- Public Member Functions inherited from UtlContainable
virtual ~UtlContainable ()
 
unsigned directHash () const
 Provides a hash function that uses the object pointer as the hash value. More...
 
virtual UtlBoolean isEqual (UtlContainable const *) const
 Test this object to another object for equality. More...
 
virtual UtlBoolean isInstanceOf (const UtlContainableType type) const
 Determine if this object is a derivative of the specified UtlContainableType. More...
 

Static Public Member Functions

static UtlBoolean socketInit ()
 
static unsigned long initDefaultAdapterID (UtlString &adapter_id)
 
static void setDefaultBindAddress (const unsigned long bind_address)
 
static const char * ipProtocolString (OsSocket::IpProtocolSocketType)
 return the string representation of the SocketProtocolType More...
 
static void getDomainName (UtlString &domain_name)
 
static unsigned long getDefaultBindAddress ()
 
static void getHostName (UtlString *hostName)
 
static void getHostIp (UtlString *hostAddress)
 
static UtlBoolean isIp4Address (const char *address)
 
static UtlBoolean isMcastAddr (const char *ipAddress)
 
static UtlBoolean isLocalHost (const char *hostAddress)
 
static UtlBoolean isSameHost (const char *host1, const char *host2)
 
static UtlBoolean getHostIpByName (const char *hostName, UtlString *hostAddress)
 
static void inet_ntoa_pt (struct in_addr input_address, UtlString &output_address)
 
static UtlBoolean isFramed (IpProtocolSocketType type)
 
- Static Public Member Functions inherited from UtlContainable
static unsigned stringHash (char const *value)
 Provides a hash function appropriate for null-terminated string values. More...
 
static UtlBoolean areSameTypes (const UtlContainableType type1, const UtlContainableType type2)
 Are UtlContainable types the same. More...
 

Static Public Attributes

static UtlBoolean socketInitialized = FALSE
 
- Static Public Attributes inherited from UtlContainable
static const UtlContainableType TYPE = "UtlContainable"
 

Protected Attributes

OsAtomicLightInt socketDescriptor
 
int localHostPort
 
int remoteHostPort
 
UtlString mLocalIp
 
UtlString localHostName
 
UtlString remoteHostName
 
UtlString mRemoteIpAddress
 
UtlBoolean mIsConnected
 

Static Protected Attributes

static const UtlContainableType TYPE = "OsSocket"
 Class type used for runtime checking. More...
 
static OsBSem mInitializeSem
 

Member Enumeration Documentation

Enumerator
UNKNOWN 
TCP 
UDP 
MULTICAST 
SSL_SOCKET 
CUSTOM 

Constructor & Destructor Documentation

OsSocket ( )
~OsSocket ( )
virtual

Member Function Documentation

UtlContainableType getContainableType ( ) const
virtual

Determine whether or not the values in a containable are comparable.

This returns a unique type for UtlString

Implements UtlContainable.

UtlBoolean socketInit ( )
static
unsigned long initDefaultAdapterID ( UtlString adapter_id)
static
virtual int write ( const char *  buffer,
int  bufferLength,
const char *  ipAddress,
int  port 
)
inlinevirtual
int write ( const char *  buffer,
int  bufferLength 
)
virtual
int write ( const char *  buffer,
int  bufferLength,
long  waitMilliseconds 
)
virtual

param: buffer - The bytes to be written to the socket. param: bufferLength - The number of bytes contained in buffer. returns: The number of bytes actually written to the socket. returns:
Note: This does not necessarily mean that the bytes were returns: actually received on the other end.

Reimplemented in OsNatDatagramSocket, and OsNatConnectionSocket.

int read ( char *  buffer,
int  bufferLength 
)
virtual

param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero, in which case it does not block.

Reimplemented in OsNatDatagramSocket, OsNatConnectionSocket, OsDatagramSocket, and OsConnectionSocket.

int read ( char *  buffer,
int  bufferLength,
UtlString ipAddress,
int *  port 
)
virtual

param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. returns: The number of bytes actually read.

Reimplemented in OsNatDatagramSocket, OsNatConnectionSocket, and OsConnectionSocket.

int read ( char *  buffer,
int  bufferLength,
struct in_addr *  ipAddress,
int *  port 
)
virtual

param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. param: ipAddress - The address of the socket that sent the bytes read. param: port - The port of the socket that sent the bytes read. returns: The number of bytes actually read.

Reimplemented in OsNatDatagramSocket, and OsNatConnectionSocket.

int read ( char *  buffer,
int  bufferLength,
long  waitMilliseconds 
)
virtual

param: buffer - Place to put bytes read from the socket. param: bufferLength - The maximum number of bytes buffer will hold. param: ipAddress - The address of the socket that sent the bytes read. param: port - The port of the socket that sent the bytes read. returns: The number of bytes actually read.

Reimplemented in OsNatDatagramSocket, OsNatConnectionSocket, and OsConnectionSocket.

void close ( )
virtual

param: waitMilliseconds - The maximum number of milliseconds to block. This may be set to zero in which case it does not block.

void makeNonblocking ( )
virtual
void makeBlocking ( )
virtual
void setDefaultBindAddress ( const unsigned long  bind_address)
static
virtual OsSocket::IpProtocolSocketType getIpProtocol ( ) const
pure virtual
const char * ipProtocolString ( OsSocket::IpProtocolSocketType  type)
static

return the string representation of the SocketProtocolType

virtual UtlBoolean reconnect ( )
pure virtual

Implemented in OsConnectionSocket, and OsDatagramSocket.

int getSocketDescriptor ( ) const
virtual
void getDomainName ( UtlString domain_name)
static
unsigned long getDefaultBindAddress ( )
static
void getHostName ( UtlString hostName)
static
void getHostIp ( UtlString hostAddress)
static
void getLocalHostIp ( UtlString localHostAddress) const
virtual
const UtlString & getLocalIp ( ) const
virtual
virtual void setLocalIp ( const UtlString localIp)
inlinevirtual
int getLocalHostPort ( ) const
virtual
void getRemoteHostName ( UtlString remoteHostName) const
virtual
void getRemoteHostIp ( struct in_addr *  remoteHostAddress,
int *  remotePort = NULL 
)
virtual

Reimplemented in OsDatagramSocket.

void getRemoteHostIp ( UtlString remoteHostAddress,
int *  remotePort = NULL 
)
virtual
int getRemoteHostPort ( ) const
virtual
UtlBoolean isOk ( ) const
virtual
UtlBoolean isConnected ( ) const
virtual
UtlBoolean isReadyToReadEx ( long  waitMilliseconds,
UtlBoolean rSocketError 
) const
virtual
UtlBoolean isReadyToRead ( long  waitMilliseconds = 0) const
virtual
UtlBoolean isReadyToWrite ( long  waitMilliseconds = 0) const
virtual
UtlBoolean isIp4Address ( const char *  address)
static
UtlBoolean isMcastAddr ( const char *  ipAddress)
static
UtlBoolean isLocalHost ( const char *  hostAddress)
static
UtlBoolean isSameHost ( const char *  host1,
const char *  host2 
)
static
UtlBoolean getHostIpByName ( const char *  hostName,
UtlString hostAddress 
)
static
void inet_ntoa_pt ( struct in_addr  input_address,
UtlString output_address 
)
static
UtlBoolean isFramed ( IpProtocolSocketType  type)
static

Member Data Documentation

UtlBoolean socketInitialized = FALSE
static
const UtlContainableType TYPE = "OsSocket"
staticprotected

Class type used for runtime checking.

OsBSem mInitializeSem
staticprotected
OsAtomicLightInt socketDescriptor
protected
int localHostPort
protected
int remoteHostPort
protected
UtlString mLocalIp
protected
UtlString localHostName
protected
UtlString remoteHostName
protected
UtlString mRemoteIpAddress
protected
UtlBoolean mIsConnected
protected