Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

iohandle Class Reference

Inherited by socket.

List of all members.


Detailed Description

A reference-counted I/O handle (descriptor).

An I/O handle is closed when the last remaining reference to it disappears.


Public Methods

 iohandle ()
 Creates an empty handle.

 iohandle (int fd)
 Creates a handler from a file descriptor.

int read (void *buf, unsigned int count)
 Attempts to read bytes into a data buffer.

 operator bool () const
 Returns true if this iohandle is valid.

int read_fully (void *buf, unsigned int count)
 Reads bytes into a data buffer, retrying continually until either end-of-stream or an error condition.

int write (const void *buf, int count)
 Attempts to write bytes from a data buffer.

int write_fully (const void *buf, unsigned int count)
 Writes bytes from a data buffer, retrying continually until either end-of-stream or an error condition.

int read (databuf buf, unsigned int count)
 Reads up to count bytes into a data buffer, setting the buffer's length to the number of bytes actually read.

int read_fully (databuf buf, unsigned int count)
 Reads count bytes into a data buffer, retrying continually until either end-of-stream or an error condition.

int read (databuf buf)
 Reads up to count bytes into a data buffer, up to the maximum length of the buffer.

int read_fully (databuf buf)
 Fills up a data buffer, retrying continually until either end-of-stream or an error condition.

int write (constbuf in)
 Attempts to write bytes from a data buffer.

int write_fully (constbuf in)
 Writes bytes from a data buffer, retrying continually until either end-of-stream or an error condition.

bool set_blocking (bool block)
 Sets a handle into blocking or non-blocking mode.

status stat () const
 Returns the status of the handle.

int get_fd () const
 Returns the file descriptor.

string as_string () const

Static Public Methods

pair< iohandle, iohandle > pipe ()

Protected Methods

void set_status (const status &s)


Constructor & Destructor Documentation

iohandle::iohandle  
 

Creates an empty handle.

iohandle::iohandle int    fd [explicit]
 

Creates a handler from a file descriptor.

This should only be invoked once per file descriptor.


Member Function Documentation

string iohandle::as_string   const
 

int iohandle::get_fd   const
 

Returns the file descriptor.

iohandle::operator bool   const
 

Returns true if this iohandle is valid.

pair<iohandle, iohandle> iohandle::pipe   [static]
 

int iohandle::read databuf    buf
 

Reads up to count bytes into a data buffer, up to the maximum length of the buffer.

Sets the buffer's length to the number of bytes actually read.

Returns:
if all bytes were successfully read, count; else 0.

int iohandle::read databuf    buf,
unsigned int    count
 

Reads up to count bytes into a data buffer, setting the buffer's length to the number of bytes actually read.

Returns:
the number of bytes actually read, or -1 if no bytes are available or an error occurs, or 0 on end-of-stream.

int iohandle::read void *    buf,
unsigned int    count
 

Attempts to read bytes into a data buffer.

This call may block if the handler has not been put into non-blocking mode.

Returns:
the number of bytes actually read, or -1 if no bytes are available or an error occurs, or 0 on end-of-stream.

int iohandle::read_fully databuf    buf
 

Fills up a data buffer, retrying continually until either end-of-stream or an error condition.

Sets buf's length to the number of bytes read, which is always either buf.max_length() or 0. This should never be called on a non-blocking socket because it may consume large of CPU time waiting for bytes.

Returns:
if all bytes were successfully read, count; else 0.

int iohandle::read_fully databuf    buf,
unsigned int    count
 

Reads count bytes into a data buffer, retrying continually until either end-of-stream or an error condition.

Sets buf's length to the number of bytes read, which is always either count or 0. This should never be called on a non-blocking socket because it may consume large of CPU time waiting for bytes.

Returns:
if all bytes were successfully read, count; else 0.

int iohandle::read_fully void *    buf,
unsigned int    count
 

Reads bytes into a data buffer, retrying continually until either end-of-stream or an error condition.

This should never be called on a non-blocking socket because it may consume large of CPU time waiting for bytes.

Returns:
if all bytes were successfully read, count; else 0.

bool iohandle::set_blocking bool    block
 

Sets a handle into blocking or non-blocking mode.

Returns:
true if successful.

void iohandle::set_status const status   s [protected]
 

status iohandle::stat   const
 

Returns the status of the handle.

int iohandle::write constbuf    in
 

Attempts to write bytes from a data buffer.

This call may block if the handler has not been put into non-blocking mode.

Returns:
the number of bytes actually written, or -1 if no bytes can be written or an error occurs, or 0 on end-of-stream.

int iohandle::write const void *    buf,
int    count
 

Attempts to write bytes from a data buffer.

This call may block if the handler has not been put into non-blocking mode.

Returns:
the number of bytes actually written, or -1 if no bytes can be written or an error occurs, or 0 on end-of-stream.

int iohandle::write_fully constbuf    in
 

Writes bytes from a data buffer, retrying continually until either end-of-stream or an error condition.

This should never be called on a non-blocking socket because it may consume large of CPU time waiting for bytes.

Returns:
if all bytes were successfully written, the buffer's length; else 0.

int iohandle::write_fully const void *    buf,
unsigned int    count
 

Writes bytes from a data buffer, retrying continually until either end-of-stream or an error condition.

This should never be called on a non-blocking socket because it may consume large of CPU time waiting for bytes.

Returns:
if all bytes were successfully written, count; else 0.


The documentation for this class was generated from the following file:
Generated on Fri Dec 20 13:35:10 2002 for NMSTL