lmsg::Socket Class Reference
[DMT message facility]

#include <Socket.hh>

Inheritance diagram for lmsg::Socket:

lmsg::TCPSocket lmsg::UDPSocket

List of all members.

Public Types

typedef struct sockaddr_in ipsock_t

Public Member Functions

 Socket (void)
virtual ~Socket (void)
MsgAddr getAddr (void) const
int getDebug (void) const
MsgAddr getPartner (void) const
int getRecvBuf (void) const
int getSendBuf (void) const
bool isConnected (void) const
bool isOpen (void) const
virtual error_type async (bool enable=true)
virtual error_type bind (const MsgAddr *addr)
virtual error_type connect (const MsgAddr &addr)
virtual error_type disconnect (void)
virtual error_type read (char *data, size_type len)
virtual error_type receive (Buffer **Data)
virtual error_type receive (Buffer *Data)
virtual error_type send (Buffer *b)
virtual error_type send (const MsgAddr &to, Buffer *b)
error_type wait (wtime_type maxtime) const
void setDebug (int level)
void setPool (BufferPool *pool)
void setPool (SocketPool *pool)
error_type setRecvBuf (int nBytes)
error_type setSendBuf (int nBytes)
void Return (void)

Static Public Member Functions

static error_type waitAny (wtime_type maxtime, int N, const Socket *list[])

Protected Attributes

MsgAddr myAddr
 Address of this socket.
MsgAddr mPartner
 Address of partner socket.
BufferPoolmBPool
 Pool containing buffers to be used by read().
bool mConnected
 Status bit indicating socket is connected.
int mSocket
 Socket file descriptor.


Detailed Description

Class to manipulate sockets. The socket class is a generic socket API. brief Abstract socket class.
Author:
John Zweizig
Version:
1.2; Modified October 16, 2000

Member Typedef Documentation

typedef struct sockaddr_in lmsg::Socket::ipsock_t [read]

Import the IP socket address type.


Constructor & Destructor Documentation

lmsg::Socket::Socket ( void   ) 

Construct an empty socket. brief Construct a socket.

virtual lmsg::Socket::~Socket ( void   )  [virtual]

Release the socket and delete all asociated storage. brief Destructor


Member Function Documentation

MsgAddr lmsg::Socket::getAddr ( void   )  const

Get the address to which the socket is bound. If the IP-Node portion of the address is zero, it indicates that the same port is allocated on ALL networks known by the node. brief Get socket IP address.

Returns:
The IP address to which the socket is bound socket.

int lmsg::Socket::getDebug ( void   )  const [inline]

Get the debug printout level. brief Get debug level.

Returns:
The debug printout level;

MsgAddr lmsg::Socket::getPartner ( void   )  const

Get the address of the latest communication partner of this socket. If a connection has been made, the partner address will be the address of socket to which it is connected. If no connection has been made, the address specifies the port to which a message was most recently sent or from which a message was most recently received. The IP node portion of the address may be zero if the latest message was sent to or received from the current node. brief Get socket IP address.

Returns:
The IP address to which the socket is bound socket.

int lmsg::Socket::getRecvBuf ( void   )  const

Get the system receive buffer length. brief Get the receive buffer length..

Returns:
The number of bytes allocated for the system receive buffer.

int lmsg::Socket::getSendBuf ( void   )  const

Get the system send buffer length. brief Get the send buffer length..

Returns:
The number of bytes allocated for the system send buffer.

bool lmsg::Socket::isConnected ( void   )  const [inline]

Test if the socket is connected to a partner. brief Test if socket is connected.

Returns:
true if the socket is connected.

bool lmsg::Socket::isOpen ( void   )  const [inline]

Test whether the socket is open. brief Test if socket is open.

Returns:
true if the socket is open.

virtual error_type lmsg::Socket::async ( bool  enable = true  )  [virtual]

Enable or disable asynchronous operation of the socket. If asynchronous operation is enabled, the socket will generate a SIGIO signal each time a message is received for the socket. Note that a SIGIO signal may be generated at any time after asynchronous operation has been enabled, so that SIGIO handling should be specified to the operating system before asynchronous operation is enabled. brief Allow asynchronous message handling.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).

virtual error_type lmsg::Socket::bind ( const MsgAddr addr  )  [virtual]

Bind this socket to a specified address. brief Bind socket to an address.

Parameters:
addr Address of the socket.
Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).

virtual error_type lmsg::Socket::connect ( const MsgAddr addr  )  [virtual]

Connect this socket to a specified partner socket. If the connection is successful, the socket patner address is updated. brief connect to a partner address.

Parameters:
addr Address of partner to which a connection is to be made.
Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).

virtual error_type lmsg::Socket::disconnect ( void   )  [virtual]

Disconnect the socket from a ciurrent parner. If no connection has been made, diconnect returns successfully. brief Disconnect from partner.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).

Reimplemented in lmsg::TCPSocket.

virtual error_type lmsg::Socket::read ( char *  data,
size_type  len 
) [virtual]

Read data from a socket. brief Receive a message.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).
Parameters:
data Address of data buffer.
len Number of bytes to read.

virtual error_type lmsg::Socket::receive ( Buffer **  Data  )  [virtual]

Receive a message from a partner socket. If the socket is connected, the message will be received from the connected partner. If no connection has been made, the message may be received from any port. The socket partner address is updated with the IP address of the port from which the message was received. brief Receive a message.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).
Parameters:
Data Address of pointer in which the address of the buffer containing the received message will be stored.

virtual error_type lmsg::Socket::receive ( Buffer Data  )  [virtual]

Receive a message from a partner socket. If the socket is connected, the message will be received from the connected partner. If no connection has been made, the message may be received from any port. The socket partner address is updated with the IP address of the port from which the message was received. brief Receive a message.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).
Parameters:
Data Address of the buffer to receive the message.

virtual error_type lmsg::Socket::send ( Buffer b  )  [virtual]

Send a message to a specified partner. brief Send a message.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).
Parameters:
b Buffer containing the message to be sent.

virtual error_type lmsg::Socket::send ( const MsgAddr to,
Buffer b 
) [virtual]

Send a message to a specified partner. brief Send a message.

Returns:
Standard lmsg error codes (OK, NotOpen or SystemError).
Parameters:
to Address of port to which the message will be sent.
b Buffer containing the message to be sent.

error_type lmsg::Socket::wait ( wtime_type  maxtime  )  const

Wait a specified maximum time or until a message is received. Wait can be used to test for an available message by specifying a zero wait time or to wait forever until a message is received by specifying a negative wait time; brief Wait for a message.

Returns:
lmsg error codes (OK, NotOpen, SystemError or TimeOut).
Parameters:
maxtime Maximum time to wait in seconds.

static error_type lmsg::Socket::waitAny ( wtime_type  maxtime,
int  N,
const Socket list[] 
) [static]

Wait a specified maximum time or until a message is received by one or more Sockets. Wait can be used to test for an available message by specifying a zero wait time or to wait forever until a message is received by specifying a negative wait time; brief Wait for a message.

Returns:
lmsg error code (OK, NotOpen, Continue, SystemError or TimeOut).
Parameters:
maxtime Maximum wait time in seconds.
N Number of socket in the list.
list List of sockets to be waited on.

void lmsg::Socket::setDebug ( int  level  ) 

Specify the debug message level. brief Specify a debug level.

Parameters:
level of debug messages to be printed.

void lmsg::Socket::setPool ( BufferPool pool  ) 

Specify a buffer pool to be used for received messages. brief Specify a buffer pool.

Parameters:
pool Pointer to the buffer pool

void lmsg::Socket::setPool ( SocketPool pool  ) 

Specify a pool of which this socket is to be a member. brief Specify asocket pool.

Parameters:
pool Pointer to the socket pool

error_type lmsg::Socket::setRecvBuf ( int  nBytes  ) 

Specify a system receive buffer size. brief Specify receive buffer length.

Parameters:
nBytes Receive buffer length

error_type lmsg::Socket::setSendBuf ( int  nBytes  ) 

Specify a system send buffer size. brief Specify send buffer length.

Parameters:
nBytes Send buffer length

void lmsg::Socket::Return ( void   ) 

Return the socket to its pool. brief Return Socket to its pool.


The documentation for this class was generated from the following file:
Generated on Sun Mar 8 19:21:35 2009 for dmt by  doxygen 1.5.4