AndroMeta  2.0.0
Public Member Functions | Static Public Member Functions | Friends
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

Constructor.

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

Destructor.


Member Function Documentation

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

Close the socket connection.

Parameters:
manualtrue 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.
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 
)

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::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::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.
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.

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