The socket server. This class contains all code for the server. The server listens for new socket connections and spawns new worker.h threads when new connections are established. More...
#include <server.h>
Public Member Functions | |
Server (int port) | |
void | start () |
void | stop () |
Private Member Functions | |
void | error (const char *msg) |
void | killConnection () |
void | newJob (int *fd) |
Private Attributes | |
int | listenFd |
int | portno |
int | net_bufferSize |
bool | running |
int * | csock |
The socket server. This class contains all code for the server. The server listens for new socket connections and spawns new worker.h threads when new connections are established.
Definition at line 17 of file server.h.
Server::Server | ( | int | port | ) |
Definition at line 22 of file server.cpp.
References net_bufferSize, and portno.
void Server::error | ( | const char * | msg | ) | [private] |
Echoes error message to stdout
msg | The message to echo |
Definition at line 118 of file server.cpp.
Referenced by start().
void Server::killConnection | ( | ) | [private] |
Closes the socket file descriptor.
Definition at line 105 of file server.cpp.
References headers::close, and listenFd.
void Server::newJob | ( | int * | fd | ) | [private] |
Spawns a new thread with the reference to the socket file desriptor.
fd | The reference to the socket file descriptor. |
Definition at line 130 of file server.cpp.
References Worker::comm().
Referenced by start().
void Server::start | ( | ) |
The server initialization and main loop. The Main loop is listening for new connections and spawns new worker threads
Definition at line 37 of file server.cpp.
References csock, error(), listenFd, newJob(), portno, and running.
Referenced by main().
void Server::stop | ( | ) |
Stops the server
Definition at line 90 of file server.cpp.
References headers::close, listenFd, and running.
Referenced by terminate().
int* Server::csock [private] |
int Server::listenFd [private] |
Definition at line 24 of file server.h.
Referenced by killConnection(), start(), and stop().
int Server::net_bufferSize [private] |
int Server::portno [private] |
bool Server::running [private] |