Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZServer Class Reference

#include <ZE_ZServer.h>

List of all members.


Detailed Description

ZServer server class, used to create a simple TCP game server for use with ZClient. A very simple turnaround server, all the server does is accept connections and relay all recieved data to all other clients.
Since:
0.8.3


Public Methods

 ZServer (bool verbose=false)
 Default Constructor.

virtual ~ZServer ()
 Destructor, disconnects server and frees memory.

bool Start (int maxClients, Uint16 port)
 Starts server.

void Stop ()
 Stops server.

void SetWaitTime (int wait)
 Sets wait time for recieves.

void CheckSockets ()
 Check sockets for connections or data.

int Clients ()
 Gets number of clients.

int WaitTime ()
 Gets current wait time.


Private Methods

void CloseSocket (int num)
 Closes a socket.


Private Attributes

ZEnginerEngine
 Pointer to ZEngine Object.

TCPsocket rSocket
 SDL_net socket for connection.

SDLNet_SocketSet rSocketSet
 Socket set for client connections.

TCPsocket * rClientSockets
 SDL_net TCPSockets for client connections.

int rMaxClients
 Maximum number of clients.

bool rVerbose
 Verbose setting for connection logs.

int rWaitTime
 Wait timeout setting for recieves on connection. [Defaults to 0.].


Constructor & Destructor Documentation

ZE::ZServer::ZServer bool    verbose = false
 

Default Constructor, does basic initialization. If verbose is true connection data will be added to log file.

Parameters:
verbose Sets verbose setting of client. [Defaults to false.]

virtual ZE::ZServer::~ZServer   [virtual]
 

Destructor calls ZServer::Stop().


Member Function Documentation

void ZE::ZServer::CloseSocket int    num [private]
 

Close a socket given by it's number.

Parameters:
num Socket number to close.

bool ZE::ZServer::Start int    maxClients,
Uint16    port
 

Starts server with a number of maximum clients and on a specified port.

Parameters:
maxClients Maximum number of clients possible to connect to server.
port Port to listen on for connections.
Returns:
True if server started, false otherwise.

void ZE::ZServer::Stop  
 

Closes port and disconnects all clients.

void ZE::ZServer::SetWaitTime int    wait
 

Sets wait time in milliseconds , time which ZServer::CheckSockets will wait before returning if there is no activity. Before this is called for the first time the wait time is 0.

Parameters:
wait Wait time.

void ZE::ZServer::CheckSockets  
 

Check sockets for connections or data, accepting new connections or relaying data from existing connections. Waits the specified wait period. This should be called very often to keep events flowing.

int ZE::ZServer::Clients  
 

Finds number of connected clients.

Returns:
Number of clients.

int ZE::ZServer::WaitTime  
 

Gets amount of time in milliseconds that is specified to wait for data on CheckSockets.

Returns:
Wait time.


The documentation for this class was generated from the following file:
Generated on Sun Apr 27 22:34:35 2003 for ZEngine by doxygen1.3-rc2