#include <server.h>
Collaboration diagram for Server:

Public Methods | |
| Server (EventQueue &r_inque, EventQueue &r_outque, Log &r_lgfile) | |
| virtual | ~Server () |
| virtual bool | Boot (unsigned short port) |
| virtual void | Run (void *parms) |
| Log & | ServerLog () |
Private Methods | |
| Server (const Server &) | |
| Server & | operator= (const Server &) |
| void | AcceptConnection () |
| void | InitFDs () |
| void | ProcessQueue () |
| void | ShutdownServer () |
| bool | SetNonBlocking (SOCKET s) |
Private Attributes | |
| bool | mShutdown |
| Flag to indicate that server is shutting down. | |
| fd_set | mInputFDs |
| Array of input sockets that select will test. | |
| fd_set | mOutputFDs |
| Array of output sockets that select will test. | |
| SOCKET | mAcceptor |
| Listening socket for incoming connections. | |
| sockaddr_in | mTo |
| Network address of the server port. | |
| ConnList | mConns |
| List of Connections managed by this server. | |
| int | mNumFds |
| Log & | mrLog |
| Server's log. | |
| EventQueue & | mrInQueue |
| Incoming events. | |
| EventQueue & | mrOutQueue |
| Outgoing events. | |
Definition at line 32 of file server.h.
|
||||||||||||||||
|
Constructor for Server Definition at line 16 of file server.cpp. |
|
|
Destructor for Server
Definition at line 28 of file server.cpp. References mConns. |
|
|
|
|
|
AcceptConnection handles an incoming connection request on the server's listening port by creating a Connection object for the socket.
Definition at line 174 of file server.cpp. References CONNECT_E, Connection::GetSocket(), mAcceptor, mConns, mrOutQueue, EventQueue::Push(), ServerLog(), SetNonBlocking(), and Log::Write(). Referenced by Run(). |
|
|
Boot initializes the Server and gets it ready to accept incoming Connections.
Definition at line 41 of file server.cpp. References mAcceptor, mNumFds, mTo, ServerLog(), SetNonBlocking(), and Log::Write(). Referenced by main(). |
|
|
InitFDs initializes the server's select queue and then re-registers interest in all the connection's sockets in the server's user list including the server's listening port itself.
Definition at line 211 of file server.cpp. References mAcceptor, mConns, mInputFDs, mNumFds, and mOutputFDs. Referenced by Run(). |
|
|
|
|
|
ProcessQueue attempts to process all the events contained in the eventqueue coming from our chat engine.
Definition at line 244 of file server.cpp. References CONNECT_E, DISCONNECT_E, Event::mClientId, mConns, Event::mDataLen, MESSAGE_E, Event::mEventType, mOutputFDs, Event::mpData, mrInQueue, mShutdown, NONE_E, EventQueue::Pop(), and SHUTDOWN_E. Referenced by Run(). |
|
|
Run starts the Server running to process incoming connection, input and output requests. It also executes commands from input requests. /param parms Not used. /note This should be where we begin threading. Not in Boot. /todo Polling time should runtime reconfigurable. Definition at line 103 of file server.cpp. References AcceptConnection(), DISCONNECT_E, InitFDs(), mAcceptor, mConns, MESSAGE_E, mInputFDs, mNumFds, mOutputFDs, mrOutQueue, mShutdown, ProcessQueue(), EventQueue::Push(), ServerLog(), ShutdownServer(), and Log::Write(). Referenced by StartServer(). |
|
|
ServerLog returns a reference to this server's logging utility so that messages can be written to it by its associates and aggregates.
Definition at line 314 of file server.cpp. References mrLog. Referenced by AcceptConnection(), Boot(), Connection::Disconnect(), Connection::HandleInput(), Connection::HandleOutput(), Run(), SetNonBlocking(), and ShutdownServer(). |
|
|
ServerLog returns a reference to this server's logging utility so that messages can be written to it by its associates and aggregates.
Definition at line 325 of file server.cpp. References ServerLog(), and Log::Write(). Referenced by AcceptConnection(), and Boot(). |
|
|
ShutdownServer requests each of the connections to disconnect in the server's user list, deletes the connections, and erases them from the user list. It then closes its own listening port. Definition at line 291 of file server.cpp. References DISCONNECT_E, mAcceptor, mConns, mrOutQueue, EventQueue::Push(), ServerLog(), SHUTDOWN_E, and Log::Write(). Referenced by Run(). |
|
|
Listening socket for incoming connections.
Definition at line 47 of file server.h. Referenced by AcceptConnection(), Boot(), InitFDs(), Run(), and ShutdownServer(). |
|
|
List of Connections managed by this server.
Definition at line 49 of file server.h. Referenced by AcceptConnection(), InitFDs(), ProcessQueue(), Run(), ShutdownServer(), and ~Server(). |
|
|
Array of input sockets that select will test.
|
|
|
|
|
|
Array of output sockets that select will test.
Definition at line 46 of file server.h. Referenced by InitFDs(), ProcessQueue(), and Run(). |
|
|
Incoming events.
Definition at line 53 of file server.h. Referenced by ProcessQueue(). |
|
|
Server's log.
Definition at line 52 of file server.h. Referenced by ServerLog(). |
|
|
Outgoing events.
Definition at line 54 of file server.h. Referenced by AcceptConnection(), Run(), and ShutdownServer(). |
|
|
Flag to indicate that server is shutting down.
Definition at line 44 of file server.h. Referenced by ProcessQueue(), and Run(). |
|
|
Network address of the server port.
Definition at line 48 of file server.h. Referenced by Boot(). |
1.2.17