Public Member Functions | Private Member Functions | Private Attributes

Server Class Reference

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>

List of all members.

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

Detailed Description

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.

Version:
0.1
Author:
Mats-Gøran Karlsen
Todo:
Add log to file feature.

Definition at line 17 of file server.h.


Constructor & Destructor Documentation

Server::Server ( int  port  ) 

Definition at line 22 of file server.cpp.

References net_bufferSize, and portno.


Member Function Documentation

void Server::error ( const char *  msg  )  [private]

Echoes error message to stdout

Parameters:
msg The message to echo
Version:
0.1

Definition at line 118 of file server.cpp.

Referenced by start().

void Server::killConnection (  )  [private]

Closes the socket file descriptor.

Version:
0.1

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.

Parameters:
fd The reference to the socket file descriptor.
Version:
0.1

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

Version:
0.1
Todo:
Recycle socket to allow for immediate server restart. Crash the server and restart. The socket server is not allowed to restart immediately.
Encrypt socket communication.

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

Version:
0.1

Definition at line 90 of file server.cpp.

References headers::close, listenFd, and running.

Referenced by terminate().


Member Data Documentation

int* Server::csock [private]

Definition at line 28 of file server.h.

Referenced by start().

int Server::listenFd [private]

Definition at line 24 of file server.h.

Referenced by killConnection(), start(), and stop().

int Server::net_bufferSize [private]

Definition at line 26 of file server.h.

Referenced by Server().

int Server::portno [private]

Definition at line 25 of file server.h.

Referenced by Server(), and start().

bool Server::running [private]

Definition at line 27 of file server.h.

Referenced by start(), and stop().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables