ClanSoft logo
ClanSoft logo
Entire Class Index Main Class Index Cross Index Global Index

Class CL_Network

Network component class. Starting place for all net activity in ClanLib.
Contained in: global
Derived from: none
Derived by: none
Group: Network (System)

#include <ClanLib/network.h>


public function member index:

Operations:

static void find_sessions_broadcast(std::string game_id, int port);
static void find_session_at(std::string app_id, const std::string& host_address, int port);
static bool peek_session_found();
static CL_NetSession* receive_session_found(int timeout_millis);
static void clear_sessions_found();
static CL_NetSession* create_session(std::string app_id, int port);
 

Description:


Function Member Descriptions:

CL_Network::clear_sessions_found - Clears the list of sessions found.
static void clear_sessions_found();


CL_Network::create_session - Creates a new network game.
static CL_NetSession* create_session(std::string app_id, int port);
app_id - The app ID is used to locate netsessions of the same type.
port - Port the game accepts connections on - and listens for broadcasts.
Returns - The created network game.



CL_Network::find_session_at - Searchs for games at the specified host address and port ('port').
static void find_session_at(std::string app_id, const std::string& host_address, int port);
host_address - IP address or hostname of the computer to be contacted.
port - Port which the computer contacted listens on.



CL_Network::find_sessions_broadcast - Searchs for games using UDP broadcasting at the specified 'port'.
Only games with the same 'game_id' are added to CL_Network::netsessions.
static void find_sessions_broadcast(std::string game_id, int port);
game_id - The game's ID used to locate this type of game with.
port - Broadcast UDP port.



CL_Network::peek_session_found - Returns true if any netsessions have been found. Use receive_game_found() to get the individual games found.
static bool peek_session_found();
Returns - True if any netsessions have been found.



CL_Network::receive_session_found - Returns the first netsession found. It is then removed from the list of games found. Next time it is called it will return the next in available.
The function is blocking until the specified timeout runs out. If set to zero, it will block forever until a game has been found.
Remember to delete the netsession returned after usage.
static CL_NetSession* receive_session_found(int timeout_millis);
timeout_millis - Timeout before returning if no game was found.
Returns - The netsession found, or NULL if timed out. Remember to delete the
Returns - netsession after usage.