E-MailRelay

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | List of all members
G::ReadWrite Class Referenceabstract

An abstract interface for reading and writing from a non-blocking i/o channel. More...

`#include <greadwrite.h>`

Inheritance diagram for G::ReadWrite:

## Public Types
typedef size_t | size_type
typedef ssize_t | ssize_type

## Public Member Functions
virtual ssize_type | read (char *buffer, size_type buffer_length)=0
| Reads data. More...
virtual ssize_type | write (const char *buf, size_type len)=0
| Sends data. More...
virtual bool | eWouldBlock ()=0
| See read() and write().
virtual SOCKET | fd () const =0
| Returns the file descriptor.
virtual | ~ReadWrite ()
| Destructor.

## Detailed Description

An abstract interface for reading and writing from a non-blocking i/o channel.

Eg:

ssize_t rc = s.read( buffer , buffer.size() ) ;
if( rc == 0 ) throw Disconnected() ;
else if( rc < 0 && !s.eWouldBlock() ) throw ReadError() ;
else if( rc > 0 ) got_some( buffer , rc ) ;
else /*nothing-to-do*/ ;
ssize_t rc = s.write( buffer , buffer.size() )
if( rc < 0 && !s.eWouldBlock() ) throw Disconnected() ;
else if( rc < 0 || rc < buffer.size() ) sent_some( rc < 0 ? 0 : rc ) ;
else sent_all() ;

Definition at line 49 of file greadwrite.h.

## Member Function Documentation

virtual ssize_type G::ReadWrite::read | ( | char * | buffer,
|  | size_type | buffer_length
| ) |  |
| pure virtual

Reads data.

Returns 0 if the connection has been lost. Returns -1 on error or if there is nothing to read (in which case eWouldBlock() returns true).

Implemented in GNet::DatagramSocket, GNet::StreamSocket, and GNet::Socket.

virtual ssize_type G::ReadWrite::write | ( | const char * | buf,
|  | size_type | len
| ) |  |
| pure virtual

Sends data.

Returns the amount of data sent.

If this method returns -1 then use eWouldBlock() to determine whether there was a flow control problem; if it returns -1 and eWouldBlock() returns false then the connection is lost. If it returns less than the requested length then eWouldBlock() should not be used.

Implemented in GNet::DatagramSocket, GNet::StreamSocket, and GNet::Socket.

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

- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/glib/greadwrite.h
- /tmp/slackrepo/SBo/slackrepo.S3SYfd/build_emailrelay/emailrelay-2.0.1/src/glib/greadwrite.cpp