VMime
socket Class Referenceabstract
Inheritance diagram for socket:
Collaboration diagram for socket:

Public Types

enum  Status { STATUS_WOULDBLOCK = 0xf, STATUS_WANT_READ = 0x1, STATUS_WANT_WRITE = 0x2 }
 

Public Member Functions

virtual ~socket ()
 
virtual void connect (const string &address, const port_t port)=0
 
virtual void disconnect ()=0
 
virtual bool isConnected () const =0
 
virtual bool waitForRead (const int msecs=30000)=0
 
virtual bool waitForWrite (const int msecs=30000)=0
 
virtual void receive (string &buffer)=0
 
virtual size_t receiveRaw (byte_t *buffer, const size_t count)=0
 
virtual void send (const string &buffer)=0
 
virtual void send (const char *str)=0
 
virtual void sendRaw (const byte_t *buffer, const size_t count)=0
 
virtual size_t sendRawNonBlocking (const byte_t *buffer, const size_t count)=0
 
virtual size_t getBlockSize () const =0
 
virtual unsigned int getStatus () const =0
 
virtual const string getPeerName () const =0
 
virtual const string getPeerAddress () const =0
 
virtual shared_ptr
< timeoutHandler
getTimeoutHandler ()=0
 
virtual void setTracer (shared_ptr< tracer > tracer)=0
 
virtual shared_ptr< tracergetTracer ()=0
 

Protected Member Functions

 socket ()
 
- Protected Member Functions inherited from object
 object ()
 
 object (const object &)
 
objectoperator= (const object &)
 
virtual ~object ()
 

Detailed Description

Interface for connecting to servers.

Member Enumeration Documentation

enum Status
Enumerator
STATUS_WOULDBLOCK 

The operation would block.

Retry later.

STATUS_WANT_READ 

The socket wants to read data, retry when data is available.

STATUS_WANT_WRITE 

The socket wants to write data, retry when data can be written.

Constructor & Destructor Documentation

virtual ~socket ( )
virtual
socket ( )
protected

Member Function Documentation

virtual void connect ( const string address,
const port_t  port 
)
pure virtual

Connect to the specified address and port.

Parameters
addressserver address (this can be a full qualified domain name or an IP address, doesn't matter)
portserver port

Implemented in SASLSocket.

virtual void disconnect ( )
pure virtual

Disconnect from the server.

Implemented in SASLSocket.

virtual size_t getBlockSize ( ) const
pure virtual

Return the preferred maximum block size when reading from or writing to this stream.

Returns
block size, in bytes

Implemented in SASLSocket.

Referenced by outputStreamSocketAdapter::getBlockSize(), and inputStreamSocketAdapter::getBlockSize().

virtual const string getPeerAddress ( ) const
pure virtual

Return the address of peer this socket is connected to.

Returns
numeric address of the peer

Implemented in SASLSocket.

virtual const string getPeerName ( ) const
pure virtual

Return the hostname of peer this socket is connected to.

Returns
name of the peer, or numeric address if it cannot be found

Implemented in SASLSocket.

virtual unsigned int getStatus ( ) const
pure virtual

Return the current status of this socket.

Returns
status flags for this socket

Implemented in SASLSocket.

virtual shared_ptr<timeoutHandler> getTimeoutHandler ( )
pure virtual

Return the timeout handler associated with this socket.

Returns
timeout handler, or NULL if none is set

Implemented in SASLSocket.

virtual shared_ptr<tracer> getTracer ( )
pure virtual

Return the tracer used by this socket.

Returns
tracer, or NULL if none is set

Implemented in SASLSocket.

virtual bool isConnected ( ) const
pure virtual

Test whether this socket is connected.

Returns
true if the socket is connected, false otherwise

Implemented in SASLSocket.

virtual void receive ( string buffer)
pure virtual

Receive text data from the socket.

Parameters
bufferbuffer in which to write received data

Implemented in SASLSocket.

virtual size_t receiveRaw ( byte_t buffer,
const size_t  count 
)
pure virtual

Receive raw data from the socket.

Parameters
bufferbuffer in which to write received data
countmaximum number of bytes to receive (size of buffer)
Returns
number of bytes received/written into output buffer

Implemented in SASLSocket.

virtual void send ( const string buffer)
pure virtual

Send text data to the socket.

Parameters
bufferdata to send

Implemented in SASLSocket.

virtual void send ( const char *  str)
pure virtual

Send text data to the socket.

Parameters
strnull-terminated string

Implemented in SASLSocket.

virtual void sendRaw ( const byte_t buffer,
const size_t  count 
)
pure virtual

Send raw data to the socket.

Parameters
bufferdata to send
countnumber of bytes to send (size of buffer)

Implemented in SASLSocket.

virtual size_t sendRawNonBlocking ( const byte_t buffer,
const size_t  count 
)
pure virtual

Send raw data to the socket.

Function may returns before all data is sent.

Parameters
bufferdata to send
countnumber of bytes to send (size of buffer)
Returns
number of bytes sent

Implemented in SASLSocket.

virtual void setTracer ( shared_ptr< tracer tracer)
pure virtual

Set the tracer used by this socket.

Tracer will only be used to report socket-specific events such as connection (not when sending/receiving data).

Parameters
tracertracer to use
virtual bool waitForRead ( const int  msecs = 30000)
pure virtual

Block until new data is available for reading.

The function will timeout after msecs milliseconds.

Parameters
timeoutmaximum wait time, in milliseconds (default is 30000); resolution is 10ms
Returns
true if data is available, or false if the operation timed out

Implemented in SASLSocket.

virtual bool waitForWrite ( const int  msecs = 30000)
pure virtual

Block until pending data has been written and new data can be written.

The function will timeout after msecs milliseconds.

Parameters
timeoutmaximum wait time, in milliseconds (default is 30000); resolution is 10ms
Returns
true if new data can be written immediately, or false if the operation timed out

Implemented in SASLSocket.


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