sends::raw_socket Class Reference

Socket API. More...

#include <raw_socket.hh>

Inheritance diagram for sends::raw_socket:

sends::socket_api

List of all members.

Public Member Functions

raw_socketaccept (void)
 Accept a connection request.
sock_err bind (const std::string &port)
 Bind socket to a local address.
sock_err close (void)
 Close the socket.
sock_err connect (const std::string &peer)
 connect to specied peer.
sock_err listen (const std::string &port, int lq)
 Listen for connection requests.
virtual long read_available (char *buf, long len)
 Read available data.
virtual int socket_id (void) const
 Get the socket id.
int wait_data (double nsec)
 Wait for data.
virtual long write (const char *buf, long len)
 Write data.

Protected Member Functions

 raw_socket (int fd)
 construct a socket

Protected Attributes

int mSocket


Detailed Description

Socket API.

The default socket api stuff.

Author:
J. Zweizig
Version:
1.0; modified April 24, 2008

Constructor & Destructor Documentation

sends::raw_socket::raw_socket ( int  fd  )  [protected]

construct a socket

Construct a raw_socket from an existing unix socket.

Parameters:
fd File descriptor for existing socket.


Member Function Documentation

raw_socket* sends::raw_socket::accept ( void   )  [virtual]

Accept a connection request.

Accept creates a new socket connected to the first external socket requesting a connection.

Returns:
Pointer to a new socket connected to requestor.

Implements sends::socket_api.

sock_err sends::raw_socket::bind ( const std::string &  addr  )  [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.

Parameters:
addr Local addres to which the socet is to be bound.
Returns:
Socket error code.

Implements sends::socket_api.

sock_err sends::raw_socket::close ( void   )  [virtual]

Close the socket.

Abstract method to close the socket. This method will depend strongly on the implementation.

Implements sends::socket_api.

sock_err sends::raw_socket::connect ( const std::string &  s  )  [virtual]

connect to specied peer.

Connect to the specified address.

Parameters:
s Peer socket address
Returns:
Socket error code.

Implements sends::socket_api.

sock_err sends::raw_socket::listen ( const std::string &  port,
int  lq 
) [virtual]

Listen for connection requests.

Listen to the specified port address, Queue the specified number of connection requests pending acceptance.

Parameters:
port Local port name to listen to.
lq Length of connection request queue
Returns:
Socket error code.

Implements sends::socket_api.

virtual long sends::raw_socket::read_available ( char *  buf,
long  len 
) [virtual]

Read available data.

Read up to the specified number of bytes from the socket into the buffer.

Parameters:
buf Pointer to buffer to receive data.
len Maximum length of data to be read (in bytes).
Returns:
Number of data bytes read.

Implements sends::socket_api.

int sends::raw_socket::socket_id ( void   )  const [inline, virtual]

Get the socket id.

Get a socket id number. In general this will be the system fd for the socket.

Returns:
Socket id for use in select.

Implements sends::socket_api.

int sends::raw_socket::wait_data ( double  nsec  )  [virtual]

Wait for data.

Wait at most the specified number of seconds for data to arrive for reading.

Parameters:
nsec Maximum number of seconds to wait for data
Returns:
Integer with the following values:
  • -1 Systerm error occurred (e.g. EINTR)
  • 0 Request timed out.
  • 1 data available on port.

Reimplemented from sends::socket_api.

virtual long sends::raw_socket::write ( const char *  buf,
long  len 
) [virtual]

Write data.

Write the specified number of bytes into the buffer.

Parameters:
buf Pointer to data to be written
len Length of data to be written (in bytes).
Returns:
Number of data bytes written or -1 on error.

Implements sends::socket_api.


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

Generated on Tue Jun 10 12:18:12 2008 for SENDS by  doxygen 1.5.5