Socket Server class.
More...
#include <scim_socket.h>
Socket Server class.
Class SocketServer provides basic operations to create a Socket Server, such as create, run etc.
◆ SocketServer() [1/2]
scim::SocketServer::SocketServer |
( |
int |
max_clients = -1 | ) |
|
Default constructor, do nothing.
◆ SocketServer() [2/2]
scim::SocketServer::SocketServer |
( |
const SocketAddress & |
address, |
|
|
int |
max_clients = -1 |
|
) |
| |
Constructor.
- Parameters
-
address | create a server on this address. |
max_clients | the max number of socket clients, -1 means unlimited. |
◆ ~SocketServer()
scim::SocketServer::~SocketServer |
( |
| ) |
|
◆ valid()
bool scim::SocketServer::valid |
( |
| ) |
const |
Test if the server is valid.
- Returns
- true if the socket server is valid and ready to run.
◆ create()
Create a socket on an address.
- Parameters
-
address | the address to be listen. |
- Returns
- true if OK.
◆ run()
bool scim::SocketServer::run |
( |
| ) |
|
Run the server.
- Returns
- true if it ran successfully.
◆ is_running()
bool scim::SocketServer::is_running |
( |
| ) |
const |
Check if the server is running.
- Returns
- true if it's running.
◆ shutdown()
void scim::SocketServer::shutdown |
( |
| ) |
|
◆ close_connection()
bool scim::SocketServer::close_connection |
( |
const Socket & |
socket | ) |
|
Close a client connection.
- Parameters
-
socket | the client socket object to be closed. |
- Returns
- true if the socket was closed successfully.
◆ get_error_number()
int scim::SocketServer::get_error_number |
( |
| ) |
const |
Get the number of the last occurred error.
- Returns
- the standard errno value.
◆ get_error_message()
String scim::SocketServer::get_error_message |
( |
| ) |
const |
Get the message of the last occurred error.
- Returns
- the error message corresponding to the errno.
◆ get_max_clients()
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.
◆ set_max_clients()
void scim::SocketServer::set_max_clients |
( |
int |
max_clients | ) |
|
Set the max number of clients.
- Parameters
-
max_clients | the max number of socket clients allowed to connect this server. |
◆ insert_external_socket()
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
-
sock | The external socket to be inserted. |
- Returns
- true if the socket is valid.
◆ remove_external_socket()
bool scim::SocketServer::remove_external_socket |
( |
const Socket & |
sock | ) |
|
Remove an external socket which was inserted by insert_external_socket ().
- Parameters
-
sock | The external socket to be removed. |
- Returns
- true if the socket is valid and has been removed successfully.
◆ signal_connect_accept()
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
-
slot | the slot to be connected to this signal. |
- Returns
- the Connection object of this slot-signal connection, can be used to disconnect the slot later.
◆ signal_connect_receive()
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
-
slot | the slot to be connected to this signal. |
- Returns
- the Connection object of this slot-signal connection, can be used to disconnect the slot later.
◆ signal_connect_exception()
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
-
slot | the 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: