scim  1.4.13
scim::SocketServer Class Reference

Socket Server class. More...

#include <scim_socket.h>

List of all members.

Public Member Functions

 SocketServer (int max_clients=-1)
 Default constructor, do nothing.
 SocketServer (const SocketAddress &address, int max_clients=-1)
 Constructor.
 ~SocketServer ()
 Destructor.
bool valid () const
 Test if the server is valid.
bool create (const SocketAddress &address)
 Create a socket on an address.
bool run ()
 Run the server.
bool is_running () const
 Check if the server is running.
void shutdown ()
 Shutdown the server.
bool close_connection (const Socket &socket)
 Close a client connection.
int get_error_number () const
 Get the number of the last occurred error.
String get_error_message () const
 Get the message of the last occurred error.
int get_max_clients () const
 Get the max number of socket clients.
void set_max_clients (int max_clients)
 Set the max number of clients.
bool insert_external_socket (const Socket &sock)
 Insert an external socket into the main loop.
bool remove_external_socket (const Socket &sock)
 Remove an external socket which was inserted by insert_external_socket ().
Connection signal_connect_accept (SocketServerSlotSocket *slot)
 Connect a slot to socket accept signal.
Connection signal_connect_receive (SocketServerSlotSocket *slot)
 Connect a slot to socket receive signal.
Connection signal_connect_exception (SocketServerSlotSocket *slot)
 Connect a slot to socket exception signal.

Additional Inherited Members

- Private Member Functions inherited from scim::Socket
 Socket (int id=-1)
 Create a Socket object from an already created socket_id.
 ~Socket ()
 Destructor.
int read (void *buf, size_t size) const
 Read data from socket.
int read_with_timeout (void *buf, size_t size, int timeout) const
 read data from socket with a timeout.
int write (const void *buf, size_t size) const
 Write data to socket.
int wait_for_data (int timeout=-1) const
 Wait until there are some data ready to read.
int get_id () const
 Get the socket id.
bool connect (const SocketAddress &addr) const
 Initiate a connection on a socket.
bool bind (const SocketAddress &addr) const
 Bind a socket to an address, used by SocketServer.
bool listen (int queue_length=5) const
 Listen for connections on a socket.
int accept () const
 Accept a connection on the socket, used by SocketServer.
bool create (SocketFamily family)
 Create a socket for specific family.
void close ()
 Close the socket.

Detailed Description

Socket Server class.

Class SocketServer provides basic operations to create a Socket Server, such as create, run etc.


Constructor & Destructor Documentation

scim::SocketServer::SocketServer ( int  max_clients = -1)

Default constructor, do nothing.

scim::SocketServer::SocketServer ( const SocketAddress address,
int  max_clients = -1 
)

Constructor.

Parameters:
addresscreate a server on this address.
max_clientsthe max number of socket clients, -1 means unlimited.
scim::SocketServer::~SocketServer ( )

Destructor.


Member Function Documentation

bool scim::SocketServer::valid ( ) const

Test if the server is valid.

Returns:
true if the socket server is valid and ready to run.

Reimplemented from scim::Socket.

bool scim::SocketServer::create ( const SocketAddress address)

Create a socket on an address.

Parameters:
addressthe address to be listen.
Returns:
true if OK.
bool scim::SocketServer::run ( )

Run the server.

Returns:
true if it ran successfully.
bool scim::SocketServer::is_running ( ) const

Check if the server is running.

Returns:
true if it's running.
void scim::SocketServer::shutdown ( )

Shutdown the server.

bool scim::SocketServer::close_connection ( const Socket socket)

Close a client connection.

Parameters:
socketthe client socket object to be closed.
Returns:
true if the socket was closed successfully.
int scim::SocketServer::get_error_number ( ) const

Get the number of the last occurred error.

Returns:
the standard errno value.

Reimplemented from scim::Socket.

String scim::SocketServer::get_error_message ( ) const

Get the message of the last occurred error.

Returns:
the error message corresponding to the errno.

Reimplemented from scim::Socket.

int scim::SocketServer::get_max_clients ( ) const

Get the max number of socket clients.

Returns:
the max number of socket clients allowed to connect this server.
void scim::SocketServer::set_max_clients ( int  max_clients)

Set the max number of clients.

Parameters:
max_clientsthe max number of socket clients allowed to connect this server.
bool scim::SocketServer::insert_external_socket ( const Socket sock)

Insert an external socket into the main loop.

If data is available on this socket, then the receive signal will be emitted.

Parameters:
sockThe external socket to be inserted.
Returns:
true if the socket is valid.
bool scim::SocketServer::remove_external_socket ( const Socket sock)

Remove an external socket which was inserted by insert_external_socket ().

Parameters:
sockThe external socket to be removed.
Returns:
true if the socket is valid and has been removed successfully.
Connection scim::SocketServer::signal_connect_accept ( SocketServerSlotSocket slot)

Connect a slot to socket accept signal.

Connect a slot to socket accept signal, if a client connection is accepted, this signal will be emitted.

Parameters:
slotthe slot to be connected to this signal.
Returns:
the Connection object of this slot-signal connection, can be used to disconnect the slot later.
Connection scim::SocketServer::signal_connect_receive ( SocketServerSlotSocket slot)

Connect a slot to socket receive signal.

Connect a slot to socket receive signal, if a client send data to this server, this signal will be emitted.

Parameters:
slotthe slot to be connected to this signal.
Returns:
the Connection object of this slot-signal connection, can be used to disconnect the slot later.
Connection scim::SocketServer::signal_connect_exception ( SocketServerSlotSocket slot)

Connect a slot to socket exception signal.

Connect a slot to socket exception signal, if an exception was occurred to a client connection, this signal will be emitted.

Parameters:
slotthe slot to be connected to this signal.
Returns:
the Connection object of this slot-signal connection, can be used to disconnect the slot later.

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