lmsg::TransportTCP Class Reference
[DMT message facility]

#include <TransportTCP.hh>

List of all members.

Public Types

enum  openflags { o_none, o_client = 1, o_async = 2 }

Public Member Functions

 TransportTCP (void)
 ~TransportTCP (void)
MsgAddr getAddr (void) const
bool isClient (void) const
bool isConnected (void) const
bool isOpen (void) const
index_type getDebug (void) const
error_type open (mask_type flags, const MsgAddr *addr=0)
void close (void)
error_type connect (const MsgAddr &addr)
error_type disconnect (void)
error_type receive (MsgHeader &from, char *b, size_type maxlen, wtime_type timeout=-1.0)
error_type receive (MsgHeader &from, Message &msg, wtime_type timeout=-1.0)
error_type receive (Buffer **Data, wtime_type timeout=-1.0)
error_type send (const MsgHeader &to, const char *b)
error_type send (const MsgHeader &to, const Message &b)
error_type waitMsg (wtime_type Timeout)
void Purge (void)
void setBufferPool (BufferPool *pool)
void setDebug (index_type level)
 set the debug level


Detailed Description

TransportTCP provides an API for transporting messages with the lmsg protocol. This API formats mesages with the proper headers and sends or receives the messages using the lmsg::Socket TCP/IP message API. brief Message transport API.
Author:
John Zweizig
Version:
1.1; Modified April 21, 2000.

Member Enumeration Documentation

enum lmsg::TransportTCP::openflags

Open options.


Constructor & Destructor Documentation

lmsg::TransportTCP::TransportTCP ( void   ) 

Construct a message transporter. brief TransportTCP constructor.

lmsg::TransportTCP::~TransportTCP ( void   ) 

Close any open socket and destroy the message transporter. brief TransportTCP destructor.


Member Function Documentation

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

Get the address of the current socket. brief Get address.

Returns:
Address to which the socket is bound.

bool lmsg::TransportTCP::isClient ( void   )  const [inline]

Test whether transport is a client port. brief Test for client socket.

Returns:
True if socket is client.

bool lmsg::TransportTCP::isConnected ( void   )  const

Test whether transport is connected to a peer port. brief Test for connected socket.

Returns:
True if socket is connected.

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

Test whether transport has an open socket. brief test for open socket.

Returns:
True if socket is open.

lmsg::index_type lmsg::TransportTCP::getDebug ( void   )  const [inline]

Get the current debugging level. brief Get debug level.

Returns:
Current debugging level.

error_type lmsg::TransportTCP::open ( mask_type  flags,
const MsgAddr addr = 0 
)

Open a socket with the specified option flags. An address to which the socket will be bound may be specified if desired. If no address is specified, the socket will be bound to an unused IP address. brief Open a socket.

Returns:
Lmsg error codes (OK or SysError).
Parameters:
flags Bit mask specifying socket handling options.
addr Optional IP address to which the socket is to be bound.

void lmsg::TransportTCP::close ( void   ) 

Return the socket to the appropriate pool. brief Close the socket.

error_type lmsg::TransportTCP::connect ( const MsgAddr addr  ) 

Make a connection with the specified IP address. Once a connection has been made messages may only be sent to or received from the specified partner socket. brief Connect to an IP partner address.

Returns:
Lmsg error codes (OK or SysError).
Parameters:
addr Address of partner to which the connection will be made.

error_type lmsg::TransportTCP::disconnect ( void   ) 

Disconnect from a partner. brief Disconnect from a partner.

Returns:
Lmsg error codes (OK or SysError).

error_type lmsg::TransportTCP::receive ( MsgHeader from,
char *  b,
size_type  maxlen,
wtime_type  timeout = -1.0 
)

A message is received. The header of the message is copied to 'from' and the message text (up to the specified maximum length) is copied to 'b'. The buffer pointer may be coded as zero if the maximum length is zero. receive returns with a TimeOut error code if no message is received within 'timeout' seconds. If 'timeout' < 0, receive will not return until either a message is received, or the the wait is interrupted by a caught signal. brief Receive a message.

Returns:
Lmsg error codes (OK, TimeOut, Continue, SysError).
Parameters:
from Received message header.
b Pointer to the buffer to receive the message text;
maxlen Length of buffer 'b'.
timeout Maximum time in seconds to wait for a message.

error_type lmsg::TransportTCP::receive ( MsgHeader from,
Message msg,
wtime_type  timeout = -1.0 
)

A message is received. The header of the message is copied to 'from' and the message text (up to the specified maximum length) is copied to 'msg'. receive returns with a TimeOut error code if no message is received within 'timeout' seconds. If 'timeout' < 0, receive will not return until either a message is received, or the the wait is interrupted by a caught signal. brief Receive a message.

Returns:
Lmsg error codes (OK, TimeOut, Continue, SysError).
Parameters:
from Received message header.
msg Message buffer to receive the message text;
timeout Maximum time in seconds to wait for a message.

error_type lmsg::TransportTCP::receive ( Buffer **  Data,
wtime_type  timeout = -1.0 
)

A message is received. The messge header and text are returned in a Buffer, the address of which is stored in 'Data'. The Buffer must be returned to the appropriate buffer pool with Data->Return() once the buffer is no longer needed. receive returns with a TimeOut error code if no message is received within 'timeout' seconds. If 'timeout' < 0, receive will not return until either a message is received, or it is interrupted by a caught signal. brief Receive a message.

Returns:
Lmsg error codes (OK, TimeOut, Continue, SysError).
Parameters:
Data Pointer to receive the filled buffer address.
timeout Maximum time in seconds to wait for a message.

error_type lmsg::TransportTCP::send ( const MsgHeader to,
const char *  b 
)

A message is sent. The header of the message to be sent is supplied by 'to' which must contain the destination address, the message type and the length of the message text. The message text is contained in 'b'. brief Send a message.

Returns:
Lmsg error codes (OK, Continue, SysError).
Parameters:
to Message header.
b Pointer to the buffer containing the message text;

error_type lmsg::TransportTCP::send ( const MsgHeader to,
const Message b 
)

A message is sent. The header of the message to be sent is supplied by 'to' which must contain the destination address and the transaction and block IDs. The message text is contained in 'b'. brief Send a message.

Returns:
Lmsg error codes (OK, Continue, SysError).
Parameters:
to Message header.
b Message to be sent.

error_type lmsg::TransportTCP::waitMsg ( wtime_type  Timeout  ) 

Wait for a message or a timeout. brief Wait for a message.

Returns:
Lmsg error codes (OK, Continue, SysError).
Parameters:
Timeout Timeout time.

void lmsg::TransportTCP::Purge ( void   ) 

Delete a socket. This method is to be used only for sockets that are broken in some way e.g. unexpected messages have been received over the buffer.

void lmsg::TransportTCP::setBufferPool ( BufferPool pool  ) 

Specify the pool from which buffers will be allocated to hold sent or received messages. brief Specify buffer pool.

Parameters:
pool Pointer to the buffer pool.

void lmsg::TransportTCP::setDebug ( index_type  level  ) 

set the debug level

Set the debugging level.

Parameters:
level Debug level.


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