Meta::MSocket Class Reference

TCP socket for network communication. More...

#include <MSocket.h>

Inheritance diagram for Meta::MSocket:
Meta::MCommunicator Meta::MNetProc

List of all members.

Public Member Functions

 MSocket ()
virtual ~MSocket ()
bool connect (const mstr &host, int port)
virtual void onConnect ()
virtual void close (bool manual=true)
int send (char *buf, size_t len)
int send (char *buf, size_t len, const mtime &timeout)
int receive (char *buf, size_t len)
int receive (char *buf, size_t len, const mtime &time)
const mstrhost ()

Static Public Member Functions

static bool isLocalHost (const mstr &host)

Friends

class MSocket_

Detailed Description

TCP socket for network communication.


Constructor & Destructor Documentation

Meta::MSocket::MSocket (  ) 

Constructor.

virtual Meta::MSocket::~MSocket (  )  [virtual]

Destructor.


Member Function Documentation

virtual void Meta::MSocket::close ( bool  manual = true  )  [virtual]

Close the socket connection.

Parameters:
manual true if the socket was closed manually, as opposed to transmission error/loss of connection.

Reimplemented in Meta::MCommunicator.

bool Meta::MSocket::connect ( const mstr host,
int  port 
)

Connect to a host.

Returns:
true on success.
const mstr& Meta::MSocket::host (  ) 
Returns:
the hostname/IP address of the remote host.
static bool Meta::MSocket::isLocalHost ( const mstr host  )  [static]
Returns:
true if host is the localhost.
virtual void Meta::MSocket::onConnect (  )  [virtual]

Called when this socket successfully connects. Useful when MSocket is extended.

Reimplemented in Meta::MCommunicator.

int Meta::MSocket::receive ( char *  buf,
size_t  len,
const mtime time 
)

Receive a data buffer of length len, blocking until completion or timeout is reached.

Returns:
The number of bytes successfully sent, -1 upon error, or 0 for connection closed.
int Meta::MSocket::receive ( char *  buf,
size_t  len 
)

Receive a data buffer of length len, blocking until completion.

Returns:
The number of bytes successfully sent, -1 upon error, or 0 for connection closed.
int Meta::MSocket::send ( char *  buf,
size_t  len,
const mtime timeout 
)

Send a data buffer of length len, blocking until all data is transmitted or timeout is reached.

Returns:
The number of bytes successfully sent, -1 upon error, or 0 on connection closed.
int Meta::MSocket::send ( char *  buf,
size_t  len 
)

Send a data buffer of length len, blocking until all data is transmitted.

Returns:
The number of bytes successfully sent, -1 upon error, or 0 on connection closed.

The documentation for this class was generated from the following file:

Generated on Wed Mar 24 16:22:43 2010 for AndroMeta by  doxygen 1.6.1