classconnection.html
来自「仿真人工智能是指用人工的方法和技术」· HTML 代码 · 共 536 行 · 第 1/2 页
HTML
536 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Connection class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"><!-- Generated by Doxygen 1.2.12 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>Connection Class Reference</h1><code>#include <<a class="el" href="Connection_8h-source.html">Connection.h</a>></code><p>Collaboration diagram for Connection:<p><center><img src="classConnection__coll__graph.gif" border="0" usemap="#Connection__coll__map" alt="Collaboration graph"></center><map name="Connection__coll__map"><area href="struct__socket.html" shape="rect" coords="25,14,78,33" alt=""></map><center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classConnection-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConnection.html#a0">Connection</a> ()</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConnection.html#a1">Connection</a> (const char *hostname, int port, int iSize)</td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConnection.html#a2">~Connection</a> ()</td></tr><tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classConnection.html#a3">connect</a> (const char *host, int port)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classConnection.html#a4">disconnect</a> (void)</td></tr><tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classConnection.html#a5">isConnected</a> (void) const</td></tr><tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classConnection.html#a6">message_loop</a> (FILE *in, FILE *out)</td></tr><tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classConnection.html#a7">receiveMessage</a> (char *msg, int maxsize)</td></tr><tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classConnection.html#a8">sendMessage</a> (const char *msg)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classConnection.html#a9">show</a> (ostream os)</td></tr><tr><td colspan=2><br><h2>Private Attributes</h2></td></tr><tr><td nowrap align=right valign=top><a class="el" href="Connection_8h.html#a0">Socket</a> </td><td valign=bottom><a class="el" href="classConnection.html#o0">m_sock</a></td></tr><tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classConnection.html#o1">m_iMaxMsgSize</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This class creates creates a (socket) connection using a hostname and a port number. After the connection is created it is possible to send and receive messages from this connection. It is based on the client program supplied with the soccer server defined in client.c and created by Istuki Noda et al. <p><p>Definition at line <a class="el" href="Connection_8h-source.html#l00064">64</a> of file <a class="el" href="Connection_8h-source.html">Connection.h</a>.<hr><h2>Constructor & Destructor Documentation</h2><a name="a0" doxytag="Connection::Connection"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Connection::Connection </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Default constructor. Only sets the maximum message size. <p>Definition at line <a class="el" href="Connection_8C-source.html#l00063">63</a> of file <a class="el" href="Connection_8C-source.html">Connection.C</a>.<p>References <a class="el" href="Connection_8h-source.html#l00067">m_iMaxMsgSize</a>. </td> </tr></table><a name="a1" doxytag="Connection::Connection"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Connection::Connection </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname" nowrap> <em>hostname</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>port</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>iMaxSize</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Constructor makes a connection with the server using the connect method. <dl compact><dt><b>Parameters: </b><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>hostname</em> </td><td>string representation of host machine (string or IP number) </td></tr><tr><td valign=top><em>port</em> </td><td>port number for connection of the host machine </td></tr><tr><td valign=top><em>iMaxSize</em> </td><td>maximum message size that can be sent or received </td></tr></table></dl><p>Definition at line <a class="el" href="Connection_8C-source.html#l00072">72</a> of file <a class="el" href="Connection_8C-source.html">Connection.C</a>.<p>References <a class="el" href="Connection_8C-source.html#l00093">connect</a>(), <a class="el" href="Logger_8C-source.html#l00082">Logger::log</a>(), and <a class="el" href="Connection_8h-source.html#l00067">m_iMaxMsgSize</a>. </td> </tr></table><a name="a2" doxytag="Connection::~Connection"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> Connection::~Connection </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Deconstructor closes the connection with the server <p>Definition at line <a class="el" href="Connection_8C-source.html#l00084">84</a> of file <a class="el" href="Connection_8C-source.html">Connection.C</a>.<p>References <a class="el" href="Connection_8C-source.html#l00151">disconnect</a>(). </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="a3" doxytag="Connection::connect"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Connection::connect </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname" nowrap> <em>host</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>int </td> <td class="mdname" nowrap> <em>port</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>This method sets up a connection with the server. <dl compact><dt><b>Parameters: </b><dd><table border=0 cellspacing=2 cellpadding=0><tr><td valign=top><em>hostname</em> </td><td>string representation of host machine (string or IP number) </td></tr><tr><td valign=top><em>port</em> </td><td>port number for connection of the host machine </td></tr></table></dl><dl compact><dt><b>Returns: </b><dd>bool indicating whether connection was made </dl><p>Definition at line <a class="el" href="Connection_8C-source.html#l00093">93</a> of file <a class="el" href="Connection_8C-source.html">Connection.C</a>.<p>References <a class="el" href="Connection_8h-source.html#l00066">m_sock</a>, <a class="el" href="Connection_8h-source.html#l00054">_socket::serv_addr</a>, and <a class="el" href="Connection_8h-source.html#l00053">_socket::socketfd</a>.<p>Referenced by <a class="el" href="Connection_8C-source.html#l00072">Connection</a>(). </td> </tr></table><a name="a4" doxytag="Connection::disconnect"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void Connection::disconnect </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>This method closes the current socket connection. <p>Definition at line <a class="el" href="Connection_8C-source.html#l00151">151</a> of file <a class="el" href="Connection_8C-source.html">Connection.C</a>.<p>References <a class="el" href="Connection_8C-source.html#l00162">isConnected</a>(), <a class="el" href="Connection_8h-source.html#l00066">m_sock</a>, and <a class="el" href="Connection_8h-source.html#l00053">_socket::socketfd</a>.<p>Referenced by <a class="el" href="main_8C-source.html#l00059">main</a>(), and <a class="el" href="Connection_8C-source.html#l00084">~Connection</a>(). </td> </tr></table><a name="a5" doxytag="Connection::isConnected"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> bool Connection::isConnected </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const</td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?