Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

scim::Socket Class Reference
[Helper]

#include <scim_socket.h>

Inheritance diagram for scim::Socket:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Socket (int id=-1)
 ~Socket ()
bool valid () const
int read (void *buf, size_t size) const
int read_with_timeout (void *buf, size_t size, int timeout) const
int write (const void *buf, size_t size) const
int wait_for_data (int timeout=-1) const
int get_error_number () const
String get_error_message () const
int get_id () const

Protected Member Functions

bool connect (const SocketAddress &addr) const
bool bind (const SocketAddress &addr) const
bool listen (int queue_length=5) const
int accept () const
bool create (SocketFamily family)
void close ()

Detailed Description

class Socket provides basic operation of socket, such as bind connect, read, write etc.

This class cannot be created by user, it can only be created by class SocketClient and SocketServer.

Definition at line 146 of file scim_socket.h.


Constructor & Destructor Documentation

scim::Socket::Socket int  id = -1  ) 
 

create a Socket object from an already created socket_id.

scim::Socket::~Socket  ) 
 

destructor, call close.


Member Function Documentation

bool scim::Socket::valid  )  const
 

check if the socket is valid.

int scim::Socket::read void *  buf,
size_t  size
const
 

read data from socket.

Parameters:
buf the buffer to store the data.
size size of the buffer.
Returns:
the amount of data actually read, -1 means error occurred.

int scim::Socket::read_with_timeout void *  buf,
size_t  size,
int  timeout
const
 

read data from socket with a timeout.

Parameters:
buf the buffer to store the data.
size size of the buffer, and the amount of data to be read.
timeout time out in millisecond (1/1000 second), -1 means infinity.
Returns:
the amount of data actually read, 0 means the connection is closed, -1 means error occurred.

int scim::Socket::write const void *  buf,
size_t  size
const
 

write data to socket.

Parameters:
buf the buffer stores the data.
size size of the data to be sent.
Returns:
the amount of data acutally sent, or -1 if an error occurred.

int scim::Socket::wait_for_data int  timeout = -1  )  const
 

wait for data is ready to read.

Parameters:
timeout time out in millisecond (1/1000 second), -1 means infinity.
Returns:
> 0 if data is OK, == 0 if time is out, < 0 if an error occurred.

int scim::Socket::get_error_number  )  const
 

get the number of the last occurred error.

Reimplemented in scim::SocketServer.

String scim::Socket::get_error_message  )  const
 

get the message of the last occurred error.

Reimplemented in scim::SocketServer.

int scim::Socket::get_id  )  const
 

get the socket id.

bool scim::Socket::connect const SocketAddress addr  )  const [protected]
 

initiate a connection on a socket.

Parameters:
addr the address to be connected.

bool scim::Socket::bind const SocketAddress addr  )  const [protected]
 

bind a socket to an address, used by SocketServer.

bool scim::Socket::listen int  queue_length = 5  )  const [protected]
 

listen for connections on a socket.

Parameters:
queue_length the length of the waiting queue.

int scim::Socket::accept  )  const [protected]
 

accept a connection on the socket, used by SocketServer.

Returns:
the id of the accepted socket, or -1 if an error is occurred.

bool scim::Socket::create SocketFamily  family  )  [protected]
 

create a socket for specific family.

void scim::Socket::close  )  [protected]
 

close the socket.

Reimplemented in scim::SocketClient.


The documentation for this class was generated from the following file:
Generated on Fri May 7 17:27:34 2004 for scim by doxygen 1.3.6