#include <socket_api.hh>

Public Types | |
| enum | sock_err { serr_OK = 0, serr_failure, serr_retry, serr_internal } |
Public Member Functions | |
| socket_api (void) | |
| Constructor. | |
| virtual | ~socket_api (void) |
| Destructor. | |
| virtual socket_api * | accept (void)=0 |
| Accept a connection request. | |
| virtual sock_err | bind (const std::string &addr)=0 |
| Bind socket to a local address. | |
| virtual sock_err | close (void)=0 |
| Close the socket. | |
| virtual sock_err | connect (const std::string &s)=0 |
| connect to specied peer. | |
| sock_err | error (void) const |
| get error code. | |
| virtual long | gets (char *buf, long len, char term='\n') |
| Read a terminated data string. | |
| virtual sock_err | handshake (void) |
| Handhake with connecting peer socket. | |
| virtual sock_err | listen (const std::string &port, int lq)=0 |
| Listen for connection requests. | |
| const char * | peer_name (void) const |
| virtual long | read (char *buf, long len) |
| Read data. | |
| virtual long | read_available (char *buf, long len)=0 |
| Read available data. | |
| void | set_error (sock_err err) |
| Set the error code. | |
| sock_err | set_error (void) |
| Set the error code from system codes. | |
| void | set_verbose (int verb) |
| Set the verbosity. | |
| virtual int | socket_id (void) const =0 |
| Get the socket id. | |
| int | verbose (void) const |
| Set the verbosity. | |
| virtual long | write (const char *buf, long len)=0 |
| Write data. | |
| virtual int | wait_data (double nsec) |
| Wait for data. | |
Static Public Member Functions | |
| static sock_err | parse_addr (const std::string &addr, unsigned int &node, unsigned short &port) |
| Parse an IP address. | |
Protected Attributes | |
| sock_err | mError |
| Status of most recent method. | |
| int | mVerbose |
| Error print-out verbosity level. | |
| std::string | mPeer |
| Peer name. | |
The socket API defines the basic functions needed for manipulating a socket.
Enumerated socket errors.
| sends::socket_api::socket_api | ( | void | ) |
Constructor.
Construct a socket.
| virtual sends::socket_api::~socket_api | ( | void | ) | [virtual] |
Destructor.
Close the socket ans destry the local data.
| virtual socket_api* sends::socket_api::accept | ( | void | ) | [pure virtual] |
Accept a connection request.
Accept creates a new socket connected to the first external socket requesting a connection.
Implemented in sends::raw_socket, and sends::ssl_bio.
| virtual sock_err sends::socket_api::bind | ( | const std::string & | addr | ) | [pure virtual] |
Bind socket to a local address.
Bind the socket to a local address. If the IP address is zero the socket will be bound to all local networks. If the port number is zero or omitted, the next available port is allocated.
| addr | Local addres to which the socet is to be bound. |
Implemented in sends::raw_socket, and sends::ssl_bio.
| virtual sock_err sends::socket_api::close | ( | void | ) | [pure virtual] |
Close the socket.
Abstract method to close the socket. This method will depend strongly on the implementation.
Implemented in sends::raw_socket, and sends::ssl_bio.
| virtual sock_err sends::socket_api::connect | ( | const std::string & | s | ) | [pure virtual] |
connect to specied peer.
Connect to the specified address.
| s | Peer socket address |
Implemented in sends::raw_socket, and sends::ssl_bio.
| socket_api::sock_err sends::socket_api::error | ( | void | ) | const [inline] |
get error code.
Get the error result from the most recent socket operation.
References mError.
| virtual long sends::socket_api::gets | ( | char * | buf, | |
| long | len, | |||
| char | term = '\n' | |||
| ) | [virtual] |
Read a terminated data string.
Read the specified number of bytes into the buffer or until a termination character is found.
| buf | Pointer to buffer to receive data. | |
| len | Maximum length of data to be read (in bytes). | |
| term | termination character |
| virtual sock_err sends::socket_api::handshake | ( | void | ) | [virtual] |
Handhake with connecting peer socket.
Perform connection handshakes. This method may be trivial in cases where no encryption or authorization takes place.
Reimplemented in sends::ssl_bio.
| virtual sock_err sends::socket_api::listen | ( | const std::string & | port, | |
| int | lq | |||
| ) | [pure virtual] |
Listen for connection requests.
Listen to the specified port address, Queue the specified number of connection requests pending acceptance.
| port | Local port name to listen to. | |
| lq | Length of connection request queue |
Implemented in sends::raw_socket, and sends::ssl_bio.
| static sock_err sends::socket_api::parse_addr | ( | const std::string & | addr, | |
| unsigned int & | node, | |||
| unsigned short & | port | |||
| ) | [static] |
Parse an IP address.
Parse a port address into an ip address and a port number. The input syntax is "address:port".
| addr | Address string. | |
| node | IP address | |
| port | Port number |
| const char * sends::socket_api::peer_name | ( | void | ) | const [inline] |
Peer name.
References mPeer.
| virtual long sends::socket_api::read | ( | char * | buf, | |
| long | len | |||
| ) | [virtual] |
| virtual long sends::socket_api::read_available | ( | char * | buf, | |
| long | len | |||
| ) | [pure virtual] |
Read available data.
Read up to the specified number of bytes from the socket into the buffer.
| buf | Pointer to buffer to receive data. | |
| len | Maximum length of data to be read (in bytes). |
Implemented in sends::raw_socket, and sends::ssl_bio.
| void sends::socket_api::set_error | ( | sock_err | err | ) |
Set the error code.
set the error code.
| err | Error code. |
| sock_err sends::socket_api::set_error | ( | void | ) |
Set the error code from system codes.
Set the socket error code based on an educated guess from errno.
| void sends::socket_api::set_verbose | ( | int | verb | ) |
Set the verbosity.
Set the verbosity level. The default level (1) prints messages for each failure.
| verb | Verbosity level. |
| virtual int sends::socket_api::socket_id | ( | void | ) | const [pure virtual] |
Get the socket id.
Get a socket id number. In general this will be the system fd for the socket.
Implemented in sends::raw_socket, and sends::ssl_bio.
| int sends::socket_api::verbose | ( | void | ) | const [inline] |
Set the verbosity.
Set the verbosity level. The default level (1) prints messages for each failure.
References mVerbose.
| virtual long sends::socket_api::write | ( | const char * | buf, | |
| long | len | |||
| ) | [pure virtual] |
Write data.
Write the specified number of bytes into the buffer.
| buf | Pointer to data to be written | |
| len | Length of data to be written (in bytes). |
Implemented in sends::raw_socket, and sends::ssl_bio.
| virtual int sends::socket_api::wait_data | ( | double | nsec | ) | [virtual] |
Wait for data.
Wait at most the specified number of seconds for data to arrive for reading.
| nsec | Maximum number of seconds to wait for data |
Reimplemented in sends::raw_socket.
1.5.5