Network Class Reference

#include <Network.h>

Collaboration diagram for Network:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Network (Level *p_level)
 Standard constructor.
virtual ~Network ()
 Standard destructor.
bool createServer (std::string p_level_name, std::string p_player_name, int p_port=37818)
 Opens a server on the given port with the given level.
std::string connect (std::string p_player_name, std::string p_address, int p_port=37818)
 Connects on the given port to a server.
bool waitForRemoteSide ()
 Waits until the remote side gives ready signal.

Protected Attributes

Level * level
 Holds the Pointer to the level.
SOCKET conSocket
 Holds the socket for the connection.

Private Member Functions

long _send (SOCKET p_socket, char p_buffer[MAXBUFFER], long p_size)
long _test (SOCKET p_socket)
long _recv (SOCKET p_socket, char p_buffer[MAXBUFFER], long p_sizemax)
SOCKET _acceptConnection (SOCKET p_socket, std::string &p_ipAddress)
int _closeConnection (SOCKET &p_socket)
SOCKET _createServer (int p_port)
SOCKET _connect (std::string p_ipAddress, int p_port)

Detailed Description

Definition at line 31 of file Network.h.


Constructor & Destructor Documentation

Network::Network ( Level *  p_level  ) 

Standard constructor.

Definition at line 27 of file Network.cpp.

References conSocket, and level.

Network::~Network (  )  [virtual]

Standard destructor.

Definition at line 33 of file Network.cpp.


Member Function Documentation

bool Network::createServer ( std::string  p_level_name,
std::string  p_player_name,
int  p_port = 37818 
)

Opens a server on the given port with the given level.

Parameters:
p_level_name Level name to sed to the client.
p_player_name Name of the player to sed.
p_port Port to listen on.
Returns:
the player name from the remote side.

Definition at line 37 of file Network.cpp.

References _acceptConnection(), _closeConnection(), _createServer(), _recv(), _send(), _test(), conSocket, MAXBUFFER, and sleep().

Referenced by WinMain().

Here is the call graph for this function:

std::string Network::connect ( std::string  p_player_name,
std::string  p_address,
int  p_port = 37818 
)

Connects on the given port to a server.

Parameters:
p_player_name Name of the local player to send.
p_address Internet address to connect to.
p_port Port to connect to.
Returns:
The level name.

Definition at line 97 of file Network.cpp.

References _closeConnection(), _connect(), _recv(), _send(), _test(), conSocket, MAXBUFFER, and sleep().

Referenced by _connect(), and WinMain().

Here is the call graph for this function:

bool Network::waitForRemoteSide (  ) 

Waits until the remote side gives ready signal.

Returns:
true if the remote site is ready.

Definition at line 164 of file Network.cpp.

Referenced by WinMain().

long Network::_send ( SOCKET  p_socket,
char  p_buffer[MAXBUFFER],
long  p_size 
) [private]

Definition at line 179 of file Network.cpp.

Referenced by connect(), and createServer().

long Network::_test ( SOCKET  p_socket  )  [private]

Definition at line 187 of file Network.cpp.

Referenced by connect(), and createServer().

long Network::_recv ( SOCKET  p_socket,
char  p_buffer[MAXBUFFER],
long  p_sizemax 
) [private]

Definition at line 195 of file Network.cpp.

Referenced by connect(), and createServer().

SOCKET Network::_acceptConnection ( SOCKET  p_socket,
std::string &  p_ipAddress 
) [private]

Definition at line 203 of file Network.cpp.

Referenced by createServer().

int Network::_closeConnection ( SOCKET &  p_socket  )  [private]

Definition at line 219 of file Network.cpp.

Referenced by connect(), and createServer().

SOCKET Network::_createServer ( int  p_port  )  [private]

Definition at line 227 of file Network.cpp.

Referenced by createServer().

SOCKET Network::_connect ( std::string  p_ipAddress,
int  p_port 
) [private]

Definition at line 272 of file Network.cpp.

References connect().

Referenced by connect().

Here is the call graph for this function:


Member Data Documentation

Level* Network::level [protected]

Holds the Pointer to the level.

Definition at line 75 of file Network.h.

Referenced by Network().

SOCKET Network::conSocket [protected]

Holds the socket for the connection.

Definition at line 80 of file Network.h.

Referenced by connect(), createServer(), and Network().


The documentation for this class was generated from the following files:
Generated on Tue Jul 17 22:02:23 2007 for C0re by  doxygen 1.5.2