<html> <head><title>ClanLib Reference: CL_Network</title></head> <body text=black link=blue vlink=#800080 bgcolor=white topmargin=0 leftmargin=0> <table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td><img border=0 src="../images/eyeheader-main-purple-a.gif" alt="ClanSoft logo" width=525 height=96></td></tr> <tr bgcolor=#dadada><td align=left valign=top><img border=0 src="../images/eyeheader-main-purple-b.gif" alt="ClanSoft logo" width=190 height=14></td><td align=right valign=top><img border=0 src="../images/clanlib_light.gif" width=42 height=14></td></tr></table> <table align=center border=0 cellspacing=10> <tr> <td><a href="entire_class_index.html">Entire Class Index</a></td> <td><a href="class_index.html">Main Class Index</a></td> <td><a href="cross_index.html">Cross Index</a></td> <td><a href="global_index.html">Global Index</a></td> </table><h1 align=center>Class CL_Network</h1><p> <b> Network component class. Starting place for all net activity in ClanLib.</b><br> Contained in: <a href="global_index.html">global</a><br> Derived from: <i>none</i> <br> Derived by: <i>none</i> <br>Group: Network (System) <p> #include <ClanLib/network.h> <p> <hr noshade> <table border=0> <tr><td colspan=3><h3>public function member index:</h3></td> <tr valign=top><td align=left><h3>Operations:</h3></td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="CL_Network.html#2874"><tt><font color=blue><b>find_sessions_broadcast</b></font></tt></a></td><td><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>game_id</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="CL_Network.html#2875"><tt><font color=blue><b>find_session_at</b></font></tt></a></td><td><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>app_id</font></tt>, <tt>const</tt> <tt><font color=navy>std::string</font></tt>& <tt><font color=blue>host_address</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>bool</font></tt></tt> </td><td align=right><a href="CL_Network.html#2876"><tt><font color=blue><b>peek_session_found</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <a href="CL_NetSession.html"><tt><font color=navy><b>CL_NetSession</b></font></tt></a>*</tt> </td><td align=right><a href="CL_Network.html#2877"><tt><font color=blue><b>receive_session_found</b></font></tt></a></td><td><tt>(<tt><font color=purple>int</font></tt> <tt><font color=blue>timeout_millis</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="CL_Network.html#2878"><tt><font color=blue><b>clear_sessions_found</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <a href="CL_NetSession.html"><tt><font color=navy><b>CL_NetSession</b></font></tt></a>*</tt> </td><td align=right><a href="CL_Network.html#2879"><tt><font color=blue><b>create_session</b></font></tt></a></td><td><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>app_id</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;</td> <tr><td> </td></table> <hr noshade> <h2>Description:</h2> <p> <hr noshade> <h2>Function Member Descriptions:</h2> <a name="2878"><font size=+1><b>CL_Network::clear_sessions_found</b></font></a> - Clears the list of sessions found.<br><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="CL_Network.html#2878"><tt><font color=blue><b>clear_sessions_found</b></font></tt></a><tt>()</tt>;<hr size="1" width="70%" align="left" noshade="noshade"><br><br> <a name="2879"><font size=+1><b>CL_Network::create_session</b></font></a> - Creates a new network game.<br><tt><tt>static</tt> <a href="CL_NetSession.html"><tt><font color=navy><b>CL_NetSession</b></font></tt></a>*</tt> <a href="CL_Network.html#2879"><tt><font color=blue><b>create_session</b></font></tt></a><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>app_id</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;<br><blockquote> app_id - The app ID is used to locate netsessions of the same type.<br> port - Port the game accepts connections on - and listens for broadcasts.<br> Returns - The created network game.</blockquote> <hr size="1" width="70%" align="left" noshade="noshade"><br><br> <a name="2875"><font size=+1><b>CL_Network::find_session_at</b></font></a> - Searchs for games at the specified host address and port ('port').<br><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="CL_Network.html#2875"><tt><font color=blue><b>find_session_at</b></font></tt></a><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>app_id</font></tt>, <tt>const</tt> <tt><font color=navy>std::string</font></tt>& <tt><font color=blue>host_address</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;<br><blockquote> host_address - IP address or hostname of the computer to be contacted.<br> port - Port which the computer contacted listens on.</blockquote> <hr size="1" width="70%" align="left" noshade="noshade"><br><br> <a name="2874"><font size=+1><b>CL_Network::find_sessions_broadcast</b></font></a> - Searchs for games using UDP broadcasting at the specified 'port'. <br> Only games with the same 'game_id' are added to CL_Network::netsessions.<br><tt><tt>static</tt> <tt><font color=purple>void</font></tt></tt> <a href="CL_Network.html#2874"><tt><font color=blue><b>find_sessions_broadcast</b></font></tt></a><tt>(<tt><font color=navy>std::string</font></tt> <tt><font color=blue>game_id</font></tt>, <tt><font color=purple>int</font></tt> <tt><font color=blue>port</font></tt>)</tt>;<br><blockquote> game_id - The game's ID used to locate this type of game with.<br> port - Broadcast UDP port.</blockquote> <hr size="1" width="70%" align="left" noshade="noshade"><br><br> <a name="2876"><font size=+1><b>CL_Network::peek_session_found</b></font></a> - Returns true if any netsessions have been found. Use receive_game_found() to get the individual games found.<br><tt><tt>static</tt> <tt><font color=purple>bool</font></tt></tt> <a href="CL_Network.html#2876"><tt><font color=blue><b>peek_session_found</b></font></tt></a><tt>()</tt>;<br><blockquote> Returns - True if any netsessions have been found.</blockquote> <hr size="1" width="70%" align="left" noshade="noshade"><br><br> <a name="2877"><font size=+1><b>CL_Network::receive_session_found</b></font></a> - 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. <br> The function is blocking until the specified timeout runs out. If set to zero, it will block forever until a game has been found.<br> Remember to delete the netsession returned after usage.<br><tt><tt>static</tt> <a href="CL_NetSession.html"><tt><font color=navy><b>CL_NetSession</b></font></tt></a>*</tt> <a href="CL_Network.html#2877"><tt><font color=blue><b>receive_session_found</b></font></tt></a><tt>(<tt><font color=purple>int</font></tt> <tt><font color=blue>timeout_millis</font></tt>)</tt>;<br><blockquote> timeout_millis - Timeout before returning if no game was found.<br> Returns - The netsession found, or NULL if timed out. Remember to delete the<br> Returns - netsession after usage.</blockquote> <hr size="1" width="70%" align="left" noshade="noshade"><br><br> <hr noshade> </body> </html>