Server side of the SimDB socket interface. This class provides the server side functions to simplify the incoming connections handling and the messages sending/receiving.
More...
#include <ServerHandler.h>
Server side of the SimDB socket interface. This class provides the server side functions to simplify the incoming connections handling and the messages sending/receiving.
int ServerHandler::acceptConnection |
( |
| ) |
|
- Returns
- The Socket descriptor of the connection just accepted, or the GENERIC_SOCKET_ERROR macro if something is wrong.
void ServerHandler::closeConnection |
( |
int |
connectedSocket, |
|
|
SocketState & |
threadState |
|
) |
| |
Chiude una connessione con un certo client
- Parameters
-
connectedSocket | The socket with the client connection. |
threadState | State of the thread which handles the connection. |
bool ServerHandler::createSocket |
( |
| ) |
|
- Returns
- true if the socket creation succeeds (through the socket() function), false otherwise.
char * ServerHandler::receiveFile |
( |
int |
connectedSocket, |
|
|
SocketState & |
threadState |
|
) |
| |
- Parameters
-
connectedSocket | The socket with the client connection. |
threadState | State of the thread which handles the connection. |
- Returns
- Pointer to the base64-encoded file. We use a pointer for efficiency reasons.
string ServerHandler::receiveMessage |
( |
int |
connectedSocket, |
|
|
SocketState & |
threadState |
|
) |
| |
Receive a message from the client.
- Parameters
-
connectedSocket | The socket whit the client connection. |
threadState | State of the thread which handles the connection. |
- Returns
- String with a message send by the client.
void ServerHandler::sendMessage |
( |
int |
connectedSocket, |
|
|
const std::string & |
message, |
|
|
SocketState & |
threadState |
|
) |
| |
- Parameters
-
connectedSocket | The socket with the client connection. |
message | The message to send to the client. |
threadState | State of the thread which handles the connection. |
bool ServerHandler::startListening |
( |
| ) |
|
- Returns
- true if the socket is ready to accept connection requests (through the bind() and listen() functions), false otherwise.
bool ServerHandler::stopService |
( |
| ) |
|
Close the listening socket and stop the server communication service.
- Returns
- true if the operation succeeds, false otherwise.
The documentation for this class was generated from the following files: