1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>InspIRCd: InspSocket Class Reference</title>
4 <link href="inspircd.doxygen.css" rel="stylesheet" type="text/css">
6 <!-- Generated by Doxygen 1.4.4-20050815 -->
7 <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div>
8 <h1>InspSocket Class Reference</h1><!-- doxytag: class="InspSocket" -->InspSocket is an extendable socket class which modules can use for TCP socket support.
9 <a href="#_details">More...</a>
11 <code>#include <<a class="el" href="socket_8h-source.html">socket.h</a>></code>
13 Collaboration diagram for InspSocket:<p><center><img src="classInspSocket__coll__graph.gif" border="0" usemap="#InspSocket__coll__map" alt="Collaboration graph"></center>
14 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><a href="classInspSocket-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
16 <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
17 <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#InspSocket_28_29">InspSocket</a> ()</td></tr>
19 <tr><td class="mdescLeft"> </td><td class="mdescRight">The default constructor does nothing and should not be used. <a href="#InspSocket_28_29"></a><br></td></tr>
20 <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#InspSocket_28int_20newfd_2C_20char_20_2Aip_29">InspSocket</a> (int newfd, char *ip)</td></tr>
22 <tr><td class="mdescLeft"> </td><td class="mdescRight">This constructor is used to associate an existing connecting with an InspSocket class. <a href="#InspSocket_28int_20newfd_2C_20char_20_2Aip_29"></a><br></td></tr>
23 <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#InspSocket_28std_3A_3Astring_20host_2C_20int_20port_2C_20bool_20listening_2C_20unsigned_20long_20maxtime_29">InspSocket</a> (<a class="el" href="namespaceirc.html#string">std::string</a> <a class="el" href="classInspSocket.html#host">host</a>, int <a class="el" href="classInspSocket.html#port">port</a>, bool listening, unsigned long maxtime)</td></tr>
25 <tr><td class="mdescLeft"> </td><td class="mdescRight">This constructor is used to create a new socket, either listening for connections, or an outbound connection to another host. <a href="#InspSocket_28std_3A_3Astring_20host_2C_20int_20port_2C_20bool_20listening_2C_20unsigned_20long_20maxtime_29"></a><br></td></tr>
26 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnConnected_28_29">OnConnected</a> ()</td></tr>
28 <tr><td class="mdescLeft"> </td><td class="mdescRight">This method is called when an outbound connection on your socket is completed. <a href="#OnConnected_28_29"></a><br></td></tr>
29 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a> (<a class="el" href="socket_8h.html#InspSocketError">InspSocketError</a> e)</td></tr>
31 <tr><td class="mdescLeft"> </td><td class="mdescRight">This method is called when an error occurs. <a href="#OnError_28InspSocketError_20e_29"></a><br></td></tr>
32 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnDisconnect_28_29">OnDisconnect</a> ()</td></tr>
34 <tr><td class="mdescLeft"> </td><td class="mdescRight">When an established connection is terminated, the OnDisconnect method is triggered. <a href="#OnDisconnect_28_29"></a><br></td></tr>
35 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnDataReady_28_29">OnDataReady</a> ()</td></tr>
37 <tr><td class="mdescLeft"> </td><td class="mdescRight">When there is data waiting to be read on a socket, the <a class="el" href="classInspSocket.html#OnDataReady_28_29">OnDataReady()</a> method is called. <a href="#OnDataReady_28_29"></a><br></td></tr>
38 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnTimeout_28_29">OnTimeout</a> ()</td></tr>
40 <tr><td class="mdescLeft"> </td><td class="mdescRight">When an outbound connection fails, and the attempt times out, you will receive this event. <a href="#OnTimeout_28_29"></a><br></td></tr>
41 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnClose_28_29">OnClose</a> ()</td></tr>
43 <tr><td class="mdescLeft"> </td><td class="mdescRight">Whenever close() is called, <a class="el" href="classInspSocket.html#OnClose_28_29">OnClose()</a> will be called first. <a href="#OnClose_28_29"></a><br></td></tr>
44 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#Read_28_29">Read</a> ()</td></tr>
46 <tr><td class="mdescLeft"> </td><td class="mdescRight">Reads all pending bytes from the socket into a char* array which can be up to 16 kilobytes in length. <a href="#Read_28_29"></a><br></td></tr>
47 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#GetIP_28_29">GetIP</a> ()</td></tr>
49 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the IP address associated with this connection, or an empty string if no IP address exists. <a href="#GetIP_28_29"></a><br></td></tr>
50 <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#Timeout_28time_5Ft_20current_29">Timeout</a> (time_t current)</td></tr>
52 <tr><td class="mdescLeft"> </td><td class="mdescRight">This function checks if the socket has timed out yet, given the current time in the parameter. <a href="#Timeout_28time_5Ft_20current_29"></a><br></td></tr>
53 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#Write_28std_3A_3Astring_20data_29">Write</a> (<a class="el" href="namespaceirc.html#string">std::string</a> data)</td></tr>
55 <tr><td class="mdescLeft"> </td><td class="mdescRight">Writes a <a class="el" href="namespaceirc.html#string">std::string</a> to the socket. <a href="#Write_28std_3A_3Astring_20data_29"></a><br></td></tr>
56 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#OnIncomingConnection_28int_20newfd_2C_20char_20_2Aip_29">OnIncomingConnection</a> (int newfd, char *ip)</td></tr>
58 <tr><td class="mdescLeft"> </td><td class="mdescRight">If your socket is a listening socket, when a new connection comes in on the socket this method will be called. <a href="#OnIncomingConnection_28int_20newfd_2C_20char_20_2Aip_29"></a><br></td></tr>
59 <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#SetState_28InspSocketState_20s_29">SetState</a> (<a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> s)</td></tr>
61 <tr><td class="mdescLeft"> </td><td class="mdescRight">Changes the socket's state. <a href="#SetState_28InspSocketState_20s_29"></a><br></td></tr>
62 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#GetState_28_29">GetState</a> ()</td></tr>
64 <tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the current socket state. <a href="#GetState_28_29"></a><br></td></tr>
65 <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#Poll_28_29">Poll</a> ()</td></tr>
67 <tr><td class="mdescLeft"> </td><td class="mdescRight">Only the core should call this function. <a href="#Poll_28_29"></a><br></td></tr>
68 <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#GetFd_28_29">GetFd</a> ()</td></tr>
70 <tr><td class="mdescLeft"> </td><td class="mdescRight">This method returns the socket's file descriptor as assigned by the operating system, or -1 if no descriptor has been assigned. <a href="#GetFd_28_29"></a><br></td></tr>
71 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#Close_28_29">Close</a> ()</td></tr>
73 <tr><td class="mdescLeft"> </td><td class="mdescRight">This method causes the socket to close, and may also be triggered by other methods such as OnTimeout and OnError. <a href="#Close_28_29"></a><br></td></tr>
74 <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#_7EInspSocket_28_29">~InspSocket</a> ()</td></tr>
76 <tr><td class="mdescLeft"> </td><td class="mdescRight">The destructor may implicitly call <a class="el" href="classInspSocket.html#OnClose_28_29">OnClose()</a>, and will close() and shutdown() the file descriptor used for this socket. <a href="#_7EInspSocket_28_29"></a><br></td></tr>
77 <tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
78 <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#fd">fd</a></td></tr>
80 <tr><td class="mdescLeft"> </td><td class="mdescRight">The file descriptor of this socket. <a href="#fd"></a><br></td></tr>
81 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#host">host</a></td></tr>
83 <tr><td class="mdescLeft"> </td><td class="mdescRight">The hostname connected to. <a href="#host"></a><br></td></tr>
84 <tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#port">port</a></td></tr>
86 <tr><td class="mdescLeft"> </td><td class="mdescRight">The port connected to, or the port this socket is listening on. <a href="#port"></a><br></td></tr>
87 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#state">state</a></td></tr>
89 <tr><td class="mdescLeft"> </td><td class="mdescRight">The state for this socket, either listening, connecting, connected or error. <a href="#state"></a><br></td></tr>
90 <tr><td class="memItemLeft" nowrap align="right" valign="top">sockaddr_in </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#addr">addr</a></td></tr>
92 <tr><td class="mdescLeft"> </td><td class="mdescRight">The host being connected to, in sockaddr form. <a href="#addr"></a><br></td></tr>
93 <tr><td class="memItemLeft" nowrap align="right" valign="top">in_addr </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#addy">addy</a></td></tr>
95 <tr><td class="mdescLeft"> </td><td class="mdescRight">The host being connected to, in in_addr form. <a href="#addy"></a><br></td></tr>
96 <tr><td class="memItemLeft" nowrap align="right" valign="top">time_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#timeout_5Fend">timeout_end</a></td></tr>
98 <tr><td class="mdescLeft"> </td><td class="mdescRight">When this time is reached, the socket times out if it is in the CONNECTING state. <a href="#timeout_5Fend"></a><br></td></tr>
99 <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#timeout">timeout</a></td></tr>
101 <tr><td class="mdescLeft"> </td><td class="mdescRight">This value is true if the socket has timed out. <a href="#timeout"></a><br></td></tr>
102 <tr><td class="memItemLeft" nowrap align="right" valign="top">char </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#ibuf_5B_31_36_33_38_34_5D">ibuf</a> [16384]</td></tr>
104 <tr><td class="mdescLeft"> </td><td class="mdescRight">Socket input buffer, used by read(). <a href="#ibuf_5B_31_36_33_38_34_5D"></a><br></td></tr>
105 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#IP">IP</a></td></tr>
107 <tr><td class="mdescLeft"> </td><td class="mdescRight">The IP address being connected to stored in string form for easy retrieval by accessors. <a href="#IP"></a><br></td></tr>
108 <tr><td class="memItemLeft" nowrap align="right" valign="top">sockaddr_in </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#client">client</a></td></tr>
110 <tr><td class="mdescLeft"> </td><td class="mdescRight">Client sockaddr structure used by accept(). <a href="#client"></a><br></td></tr>
111 <tr><td class="memItemLeft" nowrap align="right" valign="top">sockaddr_in </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#server">server</a></td></tr>
113 <tr><td class="mdescLeft"> </td><td class="mdescRight"><a class="el" href="classServer.html">Server</a> sockaddr structure used by accept(). <a href="#server"></a><br></td></tr>
114 <tr><td class="memItemLeft" nowrap align="right" valign="top">socklen_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#length">length</a></td></tr>
116 <tr><td class="mdescLeft"> </td><td class="mdescRight">Used by accept() to indicate the sizes of the sockaddr_in structures. <a href="#length"></a><br></td></tr>
118 <hr><a name="_details"></a><h2>Detailed Description</h2>
119 InspSocket is an extendable socket class which modules can use for TCP socket support.
121 It is fully integrated into InspIRCds socket loop and attaches its sockets to the core's instance of the <a class="el" href="classSocketEngine.html">SocketEngine</a> class, meaning that any sockets you create have the same power and abilities as a socket created by the core itself. To use InspSocket, you must inherit a class from it, and use the InspSocket constructors to establish connections and bindings.
125 Definition at line <a class="el" href="socket_8h-source.html#l00047">47</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
126 <a class="anchor" name="InspSocket_28_29"></a><!-- doxytag: member="InspSocket::InspSocket" ref="InspSocket_28_29" args="()" --><p>
127 <table class="mdTable" cellpadding="2" cellspacing="0">
130 <table cellpadding="0" cellspacing="0" border="0">
132 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
133 <td class="md" valign="top">( </td>
134 <td class="mdname1" valign="top" nowrap> </td>
135 <td class="md" valign="top"> ) </td>
136 <td class="md" nowrap></td>
142 <table cellspacing="5" cellpadding="0" border="0">
150 The default constructor does nothing and should not be used.
154 Definition at line <a class="el" href="socket_8cpp-source.html#l00049">49</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
156 References <a class="el" href="socket_8h.html#InspSocketStateI_5FDISCONNECTED">I_DISCONNECTED</a>, and <a class="el" href="socket_8h-source.html#l00072">state</a>.<div class="fragment"><pre class="fragment"><a name="l00050"></a>00050 {
157 <a name="l00051"></a>00051 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FDISCONNECTED">I_DISCONNECTED</a>;
158 <a name="l00052"></a>00052 }
164 <a class="anchor" name="InspSocket_28int_20newfd_2C_20char_20_2Aip_29"></a><!-- doxytag: member="InspSocket::InspSocket" ref="InspSocket_28int_20newfd_2C_20char_20_2Aip_29" args="(int newfd, char *ip)" --><p>
165 <table class="mdTable" cellpadding="2" cellspacing="0">
168 <table cellpadding="0" cellspacing="0" border="0">
170 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
171 <td class="md" valign="top">( </td>
172 <td class="md" nowrap valign="top">int </td>
173 <td class="mdname" nowrap> <em>newfd</em>, </td>
176 <td class="md" nowrap align="right"></td>
178 <td class="md" nowrap>char * </td>
179 <td class="mdname" nowrap> <em>ip</em></td>
183 <td class="md">) </td>
184 <td class="md" colspan="2"></td>
190 <table cellspacing="5" cellpadding="0" border="0">
198 This constructor is used to associate an existing connecting with an InspSocket class.
200 The given file descriptor must be valid, and when initialized, the InspSocket will be set with the given IP address and placed in CONNECTED state.
202 Definition at line <a class="el" href="socket_8cpp-source.html#l00054">54</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
204 References <a class="el" href="socketengine_8cpp-source.html#l00065">SocketEngine::AddFd()</a>, <a class="el" href="socket_8h-source.html#l00054">fd</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>, <a class="el" href="socket_8h-source.html#l00113">IP</a>, <a class="el" href="socket_8h-source.html#l00072">state</a>, and <a class="el" href="socketengine_8h-source.html#l00044">X_ESTAB_MODULE</a>.<div class="fragment"><pre class="fragment"><a name="l00055"></a>00055 {
205 <a name="l00056"></a>00056 this-><a class="code" href="classInspSocket.html#fd">fd</a> = newfd;
206 <a name="l00057"></a>00057 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>;
207 <a name="l00058"></a>00058 this-><a class="code" href="classInspSocket.html#IP">IP</a> = ip;
208 <a name="l00059"></a>00059 <a class="code" href="modules_8cpp.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#AddFd_28int_20fd_2C_20bool_20readable_2C_20char_20type_29">AddFd</a>(this->fd,<span class="keyword">true</span>,<a class="code" href="socketengine_8h.html#X_5FESTAB_5FMODULE">X_ESTAB_MODULE</a>);
209 <a name="l00060"></a>00060 }
215 <a class="anchor" name="InspSocket_28std_3A_3Astring_20host_2C_20int_20port_2C_20bool_20listening_2C_20unsigned_20long_20maxtime_29"></a><!-- doxytag: member="InspSocket::InspSocket" ref="InspSocket_28std_3A_3Astring_20host_2C_20int_20port_2C_20bool_20listening_2C_20unsigned_20long_20maxtime_29" args="(std::string host, int port, bool listening, unsigned long maxtime)" --><p>
216 <table class="mdTable" cellpadding="2" cellspacing="0">
219 <table cellpadding="0" cellspacing="0" border="0">
221 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
222 <td class="md" valign="top">( </td>
223 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
224 <td class="mdname" nowrap> <em>host</em>, </td>
227 <td class="md" nowrap align="right"></td>
229 <td class="md" nowrap>int </td>
230 <td class="mdname" nowrap> <em>port</em>, </td>
233 <td class="md" nowrap align="right"></td>
235 <td class="md" nowrap>bool </td>
236 <td class="mdname" nowrap> <em>listening</em>, </td>
239 <td class="md" nowrap align="right"></td>
241 <td class="md" nowrap>unsigned long </td>
242 <td class="mdname" nowrap> <em>maxtime</em></td>
246 <td class="md">) </td>
247 <td class="md" colspan="2"></td>
253 <table cellspacing="5" cellpadding="0" border="0">
261 This constructor is used to create a new socket, either listening for connections, or an outbound connection to another host.
263 <dl compact><dt><b>Parameters:</b></dt><dd>
264 <table border="0" cellspacing="2" cellpadding="0">
265 <tr><td valign="top"></td><td valign="top"><em>host</em> </td><td>The hostname to connect to, or bind to </td></tr>
266 <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>The port number to connect to, or bind to </td></tr>
267 <tr><td valign="top"></td><td valign="top"><em>listening</em> </td><td>true to listen on the given host:port pair, or false to connect to them </td></tr>
268 <tr><td valign="top"></td><td valign="top"><em>maxtime</em> </td><td>Number of seconds to wait, if connecting, before the connection times out and an <a class="el" href="classInspSocket.html#OnTimeout_28_29">OnTimeout()</a> event is generated</td></tr>
273 Definition at line <a class="el" href="socket_8cpp-source.html#l00062">62</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
275 References <a class="el" href="socketengine_8cpp-source.html#l00065">SocketEngine::AddFd()</a>, <a class="el" href="socket_8h-source.html#l00078">addr</a>, <a class="el" href="socket_8h-source.html#l00084">addy</a>, <a class="el" href="socket_8cpp-source.html#l00139">Close()</a>, <a class="el" href="modules_8h-source.html#l00023">DEBUG</a>, <a class="el" href="socket_8h-source.html#l00054">fd</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>, <a class="el" href="socket_8h.html#InspSocketErrorI_5FERR_5FBIND">I_ERR_BIND</a>, <a class="el" href="socket_8h.html#InspSocketErrorI_5FERR_5FCONNECT">I_ERR_CONNECT</a>, <a class="el" href="socket_8h.html#InspSocketErrorI_5FERR_5FSOCKET">I_ERR_SOCKET</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>, <a class="el" href="socket_8h-source.html#l00113">IP</a>, <a class="el" href="socket_8cpp-source.html#l00262">OnError()</a>, <a class="el" href="socket_8h-source.html#l00072">state</a>, <a class="el" href="socket_8h-source.html#l00097">timeout</a>, <a class="el" href="socket_8h-source.html#l00091">timeout_end</a>, and <a class="el" href="socketengine_8h-source.html#l00044">X_ESTAB_MODULE</a>.<div class="fragment"><pre class="fragment"><a name="l00063"></a>00063 {
276 <a name="l00064"></a>00064 <span class="keywordflow">if</span> (listening) {
277 <a name="l00065"></a>00065 <span class="keywordflow">if</span> ((this->fd = OpenTCPSocket()) == ERROR)
278 <a name="l00066"></a>00066 {
279 <a name="l00067"></a>00067 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
280 <a name="l00068"></a>00068 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
281 <a name="l00069"></a>00069 this-><a class="code" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a>(<a class="code" href="socket_8h.html#InspSocketErrorI_5FERR_5FSOCKET">I_ERR_SOCKET</a>);
282 <a name="l00070"></a>00070 log(<a class="code" href="modules_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"OpenTCPSocket() error"</span>);
283 <a name="l00071"></a>00071 <span class="keywordflow">return</span>;
284 <a name="l00072"></a>00072 }
285 <a name="l00073"></a>00073 <span class="keywordflow">else</span>
286 <a name="l00074"></a>00074 {
287 <a name="l00075"></a>00075 <span class="keywordflow">if</span> (BindSocket(this->fd,this->client,this->server,<a class="code" href="classInspSocket.html#port">port</a>,(<span class="keywordtype">char</span>*)<a class="code" href="classInspSocket.html#host">host</a>.c_str()) == ERROR)
288 <a name="l00076"></a>00076 {
289 <a name="l00077"></a>00077 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
290 <a name="l00078"></a>00078 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
291 <a name="l00079"></a>00079 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
292 <a name="l00080"></a>00080 this-><a class="code" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a>(<a class="code" href="socket_8h.html#InspSocketErrorI_5FERR_5FBIND">I_ERR_BIND</a>);
293 <a name="l00081"></a>00081 log(<a class="code" href="modules_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"BindSocket() error %s"</span>,strerror(errno));
294 <a name="l00082"></a>00082 <span class="keywordflow">return</span>;
295 <a name="l00083"></a>00083 }
296 <a name="l00084"></a>00084 <span class="keywordflow">else</span>
297 <a name="l00085"></a>00085 {
298 <a name="l00086"></a>00086 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>;
299 <a name="l00087"></a>00087 <a class="code" href="modules_8cpp.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#AddFd_28int_20fd_2C_20bool_20readable_2C_20char_20type_29">AddFd</a>(this->fd,<span class="keyword">true</span>,<a class="code" href="socketengine_8h.html#X_5FESTAB_5FMODULE">X_ESTAB_MODULE</a>);
300 <a name="l00088"></a>00088 log(<a class="code" href="modules_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"New socket now in I_LISTENING state"</span>);
301 <a name="l00089"></a>00089 <span class="keywordflow">return</span>;
302 <a name="l00090"></a>00090 }
303 <a name="l00091"></a>00091 }
304 <a name="l00092"></a>00092 } <span class="keywordflow">else</span> {
305 <a name="l00093"></a>00093 <span class="keywordtype">char</span>* ip;
306 <a name="l00094"></a>00094 this-><a class="code" href="classInspSocket.html#host">host</a> = <a class="code" href="classInspSocket.html#host">host</a>;
307 <a name="l00095"></a>00095 hostent* hoste = gethostbyname(<a class="code" href="classInspSocket.html#host">host</a>.c_str());
308 <a name="l00096"></a>00096 <span class="keywordflow">if</span> (!hoste) {
309 <a name="l00097"></a>00097 ip = (<span class="keywordtype">char</span>*)<a class="code" href="classInspSocket.html#host">host</a>.c_str();
310 <a name="l00098"></a>00098 } <span class="keywordflow">else</span> {
311 <a name="l00099"></a>00099 <span class="keyword">struct </span>in_addr* ia = (in_addr*)hoste->h_addr;
312 <a name="l00100"></a>00100 ip = inet_ntoa(*ia);
313 <a name="l00101"></a>00101 }
314 <a name="l00102"></a>00102
315 <a name="l00103"></a>00103 this-><a class="code" href="classInspSocket.html#IP">IP</a> = ip;
316 <a name="l00104"></a>00104
317 <a name="l00105"></a>00105 <a class="code" href="classInspSocket.html#timeout_5Fend">timeout_end</a> = time(NULL)+maxtime;
318 <a name="l00106"></a>00106 <a class="code" href="classInspSocket.html#timeout">timeout</a> = <span class="keyword">false</span>;
319 <a name="l00107"></a>00107 <span class="keywordflow">if</span> ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
320 <a name="l00108"></a>00108 {
321 <a name="l00109"></a>00109 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
322 <a name="l00110"></a>00110 this-><a class="code" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a>(<a class="code" href="socket_8h.html#InspSocketErrorI_5FERR_5FSOCKET">I_ERR_SOCKET</a>);
323 <a name="l00111"></a>00111 <span class="keywordflow">return</span>;
324 <a name="l00112"></a>00112 }
325 <a name="l00113"></a>00113 this-><a class="code" href="classInspSocket.html#port">port</a> = <a class="code" href="classInspSocket.html#port">port</a>;
326 <a name="l00114"></a>00114 inet_aton(ip,&<a class="code" href="classInspSocket.html#addy">addy</a>);
327 <a name="l00115"></a>00115 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_family = AF_INET;
328 <a name="l00116"></a>00116 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_addr = <a class="code" href="classInspSocket.html#addy">addy</a>;
329 <a name="l00117"></a>00117 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_port = htons(this->port);
330 <a name="l00118"></a>00118
331 <a name="l00119"></a>00119 <span class="keywordtype">int</span> flags;
332 <a name="l00120"></a>00120 flags = fcntl(this->fd, F_GETFL, 0);
333 <a name="l00121"></a>00121 fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
334 <a name="l00122"></a>00122
335 <a name="l00123"></a>00123 <span class="keywordflow">if</span>(connect(this->fd, (sockaddr*)&this->addr,<span class="keyword">sizeof</span>(this->addr)) == -1)
336 <a name="l00124"></a>00124 {
337 <a name="l00125"></a>00125 <span class="keywordflow">if</span> (errno != EINPROGRESS)
338 <a name="l00126"></a>00126 {
339 <a name="l00127"></a>00127 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
340 <a name="l00128"></a>00128 this-><a class="code" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a>(<a class="code" href="socket_8h.html#InspSocketErrorI_5FERR_5FCONNECT">I_ERR_CONNECT</a>);
341 <a name="l00129"></a>00129 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
342 <a name="l00130"></a>00130 <span class="keywordflow">return</span>;
343 <a name="l00131"></a>00131 }
344 <a name="l00132"></a>00132 }
345 <a name="l00133"></a>00133 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>;
346 <a name="l00134"></a>00134 <a class="code" href="modules_8cpp.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#AddFd_28int_20fd_2C_20bool_20readable_2C_20char_20type_29">AddFd</a>(this->fd,<span class="keyword">false</span>,<a class="code" href="socketengine_8h.html#X_5FESTAB_5FMODULE">X_ESTAB_MODULE</a>);
347 <a name="l00135"></a>00135 <span class="keywordflow">return</span>;
348 <a name="l00136"></a>00136 }
349 <a name="l00137"></a>00137 }
355 <a class="anchor" name="_7EInspSocket_28_29"></a><!-- doxytag: member="InspSocket::~InspSocket" ref="_7EInspSocket_28_29" args="()" --><p>
356 <table class="mdTable" cellpadding="2" cellspacing="0">
359 <table cellpadding="0" cellspacing="0" border="0">
361 <td class="md" nowrap valign="top">InspSocket::~InspSocket </td>
362 <td class="md" valign="top">( </td>
363 <td class="mdname1" valign="top" nowrap> </td>
364 <td class="md" valign="top"> ) </td>
365 <td class="md" nowrap><code> [virtual]</code></td>
371 <table cellspacing="5" cellpadding="0" border="0">
379 The destructor may implicitly call <a class="el" href="classInspSocket.html#OnClose_28_29">OnClose()</a>, and will close() and shutdown() the file descriptor used for this socket.
383 Definition at line <a class="el" href="socket_8cpp-source.html#l00269">269</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
385 References <a class="el" href="socket_8cpp-source.html#l00139">Close()</a>.<div class="fragment"><pre class="fragment"><a name="l00270"></a>00270 {
386 <a name="l00271"></a>00271 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
387 <a name="l00272"></a>00272 }
393 <hr><h2>Member Function Documentation</h2>
394 <a class="anchor" name="Close_28_29"></a><!-- doxytag: member="InspSocket::Close" ref="Close_28_29" args="()" --><p>
395 <table class="mdTable" cellpadding="2" cellspacing="0">
398 <table cellpadding="0" cellspacing="0" border="0">
400 <td class="md" nowrap valign="top">void InspSocket::Close </td>
401 <td class="md" valign="top">( </td>
402 <td class="mdname1" valign="top" nowrap> </td>
403 <td class="md" valign="top"> ) </td>
404 <td class="md" nowrap><code> [virtual]</code></td>
410 <table cellspacing="5" cellpadding="0" border="0">
418 This method causes the socket to close, and may also be triggered by other methods such as OnTimeout and OnError.
422 Definition at line <a class="el" href="socket_8cpp-source.html#l00139">139</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
424 References <a class="el" href="socket_8h-source.html#l00054">fd</a>, and <a class="el" href="socket_8cpp-source.html#l00267">OnClose()</a>.
426 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00269">~InspSocket()</a>.<div class="fragment"><pre class="fragment"><a name="l00140"></a>00140 {
427 <a name="l00141"></a>00141 <span class="keywordflow">if</span> (this->fd != -1)
428 <a name="l00142"></a>00142 {
429 <a name="l00143"></a>00143 this-><a class="code" href="classInspSocket.html#OnClose_28_29">OnClose</a>();
430 <a name="l00144"></a>00144 shutdown(this->fd,2);
431 <a name="l00145"></a>00145 close(this->fd);
432 <a name="l00146"></a>00146 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
433 <a name="l00147"></a>00147 }
434 <a name="l00148"></a>00148 }
440 <a class="anchor" name="GetFd_28_29"></a><!-- doxytag: member="InspSocket::GetFd" ref="GetFd_28_29" args="()" --><p>
441 <table class="mdTable" cellpadding="2" cellspacing="0">
444 <table cellpadding="0" cellspacing="0" border="0">
446 <td class="md" nowrap valign="top">int InspSocket::GetFd </td>
447 <td class="md" valign="top">( </td>
448 <td class="mdname1" valign="top" nowrap> </td>
449 <td class="md" valign="top"> ) </td>
450 <td class="md" nowrap></td>
456 <table cellspacing="5" cellpadding="0" border="0">
464 This method returns the socket's file descriptor as assigned by the operating system, or -1 if no descriptor has been assigned.
468 Definition at line <a class="el" href="socket_8cpp-source.html#l00256">256</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
470 References <a class="el" href="socket_8h-source.html#l00054">fd</a>.<div class="fragment"><pre class="fragment"><a name="l00257"></a>00257 {
471 <a name="l00258"></a>00258 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#fd">fd</a>;
472 <a name="l00259"></a>00259 }
478 <a class="anchor" name="GetIP_28_29"></a><!-- doxytag: member="InspSocket::GetIP" ref="GetIP_28_29" args="()" --><p>
479 <table class="mdTable" cellpadding="2" cellspacing="0">
482 <table cellpadding="0" cellspacing="0" border="0">
484 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> InspSocket::GetIP </td>
485 <td class="md" valign="top">( </td>
486 <td class="mdname1" valign="top" nowrap> </td>
487 <td class="md" valign="top"> ) </td>
488 <td class="md" nowrap></td>
494 <table cellspacing="5" cellpadding="0" border="0">
502 Returns the IP address associated with this connection, or an empty string if no IP address exists.
506 Definition at line <a class="el" href="socket_8cpp-source.html#l00150">150</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
508 References <a class="el" href="socket_8h-source.html#l00113">IP</a>.<div class="fragment"><pre class="fragment"><a name="l00151"></a>00151 {
509 <a name="l00152"></a>00152 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#IP">IP</a>;
510 <a name="l00153"></a>00153 }
516 <a class="anchor" name="GetState_28_29"></a><!-- doxytag: member="InspSocket::GetState" ref="GetState_28_29" args="()" --><p>
517 <table class="mdTable" cellpadding="2" cellspacing="0">
520 <table cellpadding="0" cellspacing="0" border="0">
522 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> InspSocket::GetState </td>
523 <td class="md" valign="top">( </td>
524 <td class="mdname1" valign="top" nowrap> </td>
525 <td class="md" valign="top"> ) </td>
526 <td class="md" nowrap></td>
532 <table cellspacing="5" cellpadding="0" border="0">
540 Returns the current socket state.
544 Definition at line <a class="el" href="socket_8cpp-source.html#l00251">251</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
546 References <a class="el" href="socket_8h-source.html#l00072">state</a>.<div class="fragment"><pre class="fragment"><a name="l00252"></a>00252 {
547 <a name="l00253"></a>00253 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#state">state</a>;
548 <a name="l00254"></a>00254 }
554 <a class="anchor" name="OnClose_28_29"></a><!-- doxytag: member="InspSocket::OnClose" ref="OnClose_28_29" args="()" --><p>
555 <table class="mdTable" cellpadding="2" cellspacing="0">
558 <table cellpadding="0" cellspacing="0" border="0">
560 <td class="md" nowrap valign="top">void InspSocket::OnClose </td>
561 <td class="md" valign="top">( </td>
562 <td class="mdname1" valign="top" nowrap> </td>
563 <td class="md" valign="top"> ) </td>
564 <td class="md" nowrap><code> [virtual]</code></td>
570 <table cellspacing="5" cellpadding="0" border="0">
578 Whenever close() is called, <a class="el" href="classInspSocket.html#OnClose_28_29">OnClose()</a> will be called first.
580 Please note that this means OnClose will be called alongside <a class="el" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError()</a>, <a class="el" href="classInspSocket.html#OnTimeout_28_29">OnTimeout()</a>, and <a class="el" href="classInspSocket.html#Close_28_29">Close()</a>, and also when cancelling a listening socket by calling the destructor indirectly.
582 Definition at line <a class="el" href="socket_8cpp-source.html#l00267">267</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
584 Referenced by <a class="el" href="socket_8cpp-source.html#l00139">Close()</a>.<div class="fragment"><pre class="fragment"><a name="l00267"></a>00267 { <span class="keywordflow">return</span>; }
590 <a class="anchor" name="OnConnected_28_29"></a><!-- doxytag: member="InspSocket::OnConnected" ref="OnConnected_28_29" args="()" --><p>
591 <table class="mdTable" cellpadding="2" cellspacing="0">
594 <table cellpadding="0" cellspacing="0" border="0">
596 <td class="md" nowrap valign="top">bool InspSocket::OnConnected </td>
597 <td class="md" valign="top">( </td>
598 <td class="mdname1" valign="top" nowrap> </td>
599 <td class="md" valign="top"> ) </td>
600 <td class="md" nowrap><code> [virtual]</code></td>
606 <table cellspacing="5" cellpadding="0" border="0">
614 This method is called when an outbound connection on your socket is completed.
616 <dl compact><dt><b>Returns:</b></dt><dd>false to abort the connection, true to continue</dd></dl>
619 Definition at line <a class="el" href="socket_8cpp-source.html#l00261">261</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
621 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00261"></a>00261 { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
627 <a class="anchor" name="OnDataReady_28_29"></a><!-- doxytag: member="InspSocket::OnDataReady" ref="OnDataReady_28_29" args="()" --><p>
628 <table class="mdTable" cellpadding="2" cellspacing="0">
631 <table cellpadding="0" cellspacing="0" border="0">
633 <td class="md" nowrap valign="top">bool InspSocket::OnDataReady </td>
634 <td class="md" valign="top">( </td>
635 <td class="mdname1" valign="top" nowrap> </td>
636 <td class="md" valign="top"> ) </td>
637 <td class="md" nowrap><code> [virtual]</code></td>
643 <table cellspacing="5" cellpadding="0" border="0">
651 When there is data waiting to be read on a socket, the <a class="el" href="classInspSocket.html#OnDataReady_28_29">OnDataReady()</a> method is called.
653 Within this method, you *MUST* call the <a class="el" href="classInspSocket.html#Read_28_29">Read()</a> method to read any pending data. At its lowest level, this event is signalled by the core via the socket engine. If you return false from this function, the core removes your socket from its list and erases it from the socket engine, then calls <a class="el" href="classInspSocket.html#Close_28_29">InspSocket::Close()</a> and deletes it. <dl compact><dt><b>Returns:</b></dt><dd>false to close the socket</dd></dl>
656 Definition at line <a class="el" href="socket_8cpp-source.html#l00265">265</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
658 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00265"></a>00265 { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
664 <a class="anchor" name="OnDisconnect_28_29"></a><!-- doxytag: member="InspSocket::OnDisconnect" ref="OnDisconnect_28_29" args="()" --><p>
665 <table class="mdTable" cellpadding="2" cellspacing="0">
668 <table cellpadding="0" cellspacing="0" border="0">
670 <td class="md" nowrap valign="top">int InspSocket::OnDisconnect </td>
671 <td class="md" valign="top">( </td>
672 <td class="mdname1" valign="top" nowrap> </td>
673 <td class="md" valign="top"> ) </td>
674 <td class="md" nowrap><code> [virtual]</code></td>
680 <table cellspacing="5" cellpadding="0" border="0">
688 When an established connection is terminated, the OnDisconnect method is triggered.
692 Definition at line <a class="el" href="socket_8cpp-source.html#l00263">263</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.<div class="fragment"><pre class="fragment"><a name="l00263"></a>00263 { <span class="keywordflow">return</span> 0; }
698 <a class="anchor" name="OnError_28InspSocketError_20e_29"></a><!-- doxytag: member="InspSocket::OnError" ref="OnError_28InspSocketError_20e_29" args="(InspSocketError e)" --><p>
699 <table class="mdTable" cellpadding="2" cellspacing="0">
702 <table cellpadding="0" cellspacing="0" border="0">
704 <td class="md" nowrap valign="top">void InspSocket::OnError </td>
705 <td class="md" valign="top">( </td>
706 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketError">InspSocketError</a> </td>
707 <td class="mdname1" valign="top" nowrap> <em>e</em> </td>
708 <td class="md" valign="top"> ) </td>
709 <td class="md" nowrap><code> [virtual]</code></td>
715 <table cellspacing="5" cellpadding="0" border="0">
723 This method is called when an error occurs.
725 A closed socket in itself is not an error, however errors also generate close events. <dl compact><dt><b>Parameters:</b></dt><dd>
726 <table border="0" cellspacing="2" cellpadding="0">
727 <tr><td valign="top"></td><td valign="top"><em>e</em> </td><td>The error type which occured</td></tr>
732 Definition at line <a class="el" href="socket_8cpp-source.html#l00262">262</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
734 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>.<div class="fragment"><pre class="fragment"><a name="l00262"></a>00262 { <span class="keywordflow">return</span>; }
740 <a class="anchor" name="OnIncomingConnection_28int_20newfd_2C_20char_20_2Aip_29"></a><!-- doxytag: member="InspSocket::OnIncomingConnection" ref="OnIncomingConnection_28int_20newfd_2C_20char_20_2Aip_29" args="(int newfd, char *ip)" --><p>
741 <table class="mdTable" cellpadding="2" cellspacing="0">
744 <table cellpadding="0" cellspacing="0" border="0">
746 <td class="md" nowrap valign="top">int InspSocket::OnIncomingConnection </td>
747 <td class="md" valign="top">( </td>
748 <td class="md" nowrap valign="top">int </td>
749 <td class="mdname" nowrap> <em>newfd</em>, </td>
752 <td class="md" nowrap align="right"></td>
754 <td class="md" nowrap>char * </td>
755 <td class="mdname" nowrap> <em>ip</em></td>
759 <td class="md">) </td>
760 <td class="md" colspan="2"><code> [virtual]</code></td>
766 <table cellspacing="5" cellpadding="0" border="0">
774 If your socket is a listening socket, when a new connection comes in on the socket this method will be called.
776 Given the new file descriptor in the parameters, and the IP, it is recommended you copy them to a new instance of your socket class, e.g.:<p>
777 MySocket* newsocket = new MySocket(newfd,ip);<p>
778 Once you have done this, you can then associate the new socket with the core using <a class="el" href="classServer.html#AddSocket_28InspSocket_20_2Asock_29">Server::AddSocket()</a>.
780 Definition at line <a class="el" href="socket_8cpp-source.html#l00264">264</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
782 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00264"></a>00264 { <span class="keywordflow">return</span> 0; }
788 <a class="anchor" name="OnTimeout_28_29"></a><!-- doxytag: member="InspSocket::OnTimeout" ref="OnTimeout_28_29" args="()" --><p>
789 <table class="mdTable" cellpadding="2" cellspacing="0">
792 <table cellpadding="0" cellspacing="0" border="0">
794 <td class="md" nowrap valign="top">void InspSocket::OnTimeout </td>
795 <td class="md" valign="top">( </td>
796 <td class="mdname1" valign="top" nowrap> </td>
797 <td class="md" valign="top"> ) </td>
798 <td class="md" nowrap><code> [virtual]</code></td>
804 <table cellspacing="5" cellpadding="0" border="0">
812 When an outbound connection fails, and the attempt times out, you will receive this event.
814 The mthod will trigger once maxtime secons are reached (as given in the constructor) just before the socket's descriptor is closed.
816 Definition at line <a class="el" href="socket_8cpp-source.html#l00266">266</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
818 Referenced by <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>.<div class="fragment"><pre class="fragment"><a name="l00266"></a>00266 { <span class="keywordflow">return</span>; }
824 <a class="anchor" name="Poll_28_29"></a><!-- doxytag: member="InspSocket::Poll" ref="Poll_28_29" args="()" --><p>
825 <table class="mdTable" cellpadding="2" cellspacing="0">
828 <table cellpadding="0" cellspacing="0" border="0">
830 <td class="md" nowrap valign="top">bool InspSocket::Poll </td>
831 <td class="md" valign="top">( </td>
832 <td class="mdname1" valign="top" nowrap> </td>
833 <td class="md" valign="top"> ) </td>
834 <td class="md" nowrap></td>
840 <table cellspacing="5" cellpadding="0" border="0">
848 Only the core should call this function.
850 When called, it is assumed the socket is ready to read data, and the method call routes the event to the various methods of InspSocket for you to handle. This can also cause the socket's state to change.
852 Definition at line <a class="el" href="socket_8cpp-source.html#l00214">214</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
854 References <a class="el" href="socketengine_8cpp-source.html#l00065">SocketEngine::AddFd()</a>, <a class="el" href="socket_8h-source.html#l00119">client</a>, <a class="el" href="socketengine_8cpp-source.html#l00103">SocketEngine::DelFd()</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>, <a class="el" href="socket_8h-source.html#l00131">length</a>, <a class="el" href="socket_8cpp-source.html#l00261">OnConnected()</a>, <a class="el" href="socket_8cpp-source.html#l00265">OnDataReady()</a>, <a class="el" href="socket_8cpp-source.html#l00264">OnIncomingConnection()</a>, <a class="el" href="socket_8cpp-source.html#l00245">SetState()</a>, and <a class="el" href="socketengine_8h-source.html#l00044">X_ESTAB_MODULE</a>.<div class="fragment"><pre class="fragment"><a name="l00215"></a>00215 {
855 <a name="l00216"></a>00216 <span class="keywordtype">int</span> incoming = -1;
856 <a name="l00217"></a>00217
857 <a name="l00218"></a>00218 <span class="keywordflow">switch</span> (this->state)
858 <a name="l00219"></a>00219 {
859 <a name="l00220"></a>00220 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>:
860 <a name="l00221"></a>00221 this-><a class="code" href="classInspSocket.html#SetState_28InspSocketState_20s_29">SetState</a>(<a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>);
861 <a name="l00222"></a>00222 <span class="comment">/* Our socket was in write-state, so delete it and re-add it</span>
862 <a name="l00223"></a>00223 <span class="comment"> * in read-state.</span>
863 <a name="l00224"></a>00224 <span class="comment"> */</span>
864 <a name="l00225"></a>00225 <a class="code" href="modules_8cpp.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#DelFd_28int_20fd_29">DelFd</a>(this->fd);
865 <a name="l00226"></a>00226 <a class="code" href="modules_8cpp.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#AddFd_28int_20fd_2C_20bool_20readable_2C_20char_20type_29">AddFd</a>(this->fd,<span class="keyword">true</span>,<a class="code" href="socketengine_8h.html#X_5FESTAB_5FMODULE">X_ESTAB_MODULE</a>);
866 <a name="l00227"></a>00227 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#OnConnected_28_29">OnConnected</a>();
867 <a name="l00228"></a>00228 <span class="keywordflow">break</span>;
868 <a name="l00229"></a>00229 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>:
869 <a name="l00230"></a>00230 <a class="code" href="classInspSocket.html#length">length</a> = <span class="keyword">sizeof</span> (<a class="code" href="classInspSocket.html#client">client</a>);
870 <a name="l00231"></a>00231 incoming = accept (this->fd, (sockaddr*)&<a class="code" href="classInspSocket.html#client">client</a>,&<a class="code" href="classInspSocket.html#length">length</a>);
871 <a name="l00232"></a>00232 this-><a class="code" href="classInspSocket.html#OnIncomingConnection_28int_20newfd_2C_20char_20_2Aip_29">OnIncomingConnection</a>(incoming,inet_ntoa(<a class="code" href="classInspSocket.html#client">client</a>.sin_addr));
872 <a name="l00233"></a>00233 <span class="keywordflow">return</span> <span class="keyword">true</span>;
873 <a name="l00234"></a>00234 <span class="keywordflow">break</span>;
874 <a name="l00235"></a>00235 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>:
875 <a name="l00236"></a>00236 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#OnDataReady_28_29">OnDataReady</a>();
876 <a name="l00237"></a>00237 <span class="keywordflow">break</span>;
877 <a name="l00238"></a>00238 <span class="keywordflow">default</span>:
878 <a name="l00239"></a>00239 <span class="keywordflow">break</span>;
879 <a name="l00240"></a>00240 }
880 <a name="l00241"></a>00241
881 <a name="l00242"></a>00242 <span class="keywordflow">return</span> <span class="keyword">true</span>;
882 <a name="l00243"></a>00243 }
888 <a class="anchor" name="Read_28_29"></a><!-- doxytag: member="InspSocket::Read" ref="Read_28_29" args="()" --><p>
889 <table class="mdTable" cellpadding="2" cellspacing="0">
892 <table cellpadding="0" cellspacing="0" border="0">
894 <td class="md" nowrap valign="top">char * InspSocket::Read </td>
895 <td class="md" valign="top">( </td>
896 <td class="mdname1" valign="top" nowrap> </td>
897 <td class="md" valign="top"> ) </td>
898 <td class="md" nowrap><code> [virtual]</code></td>
904 <table cellspacing="5" cellpadding="0" border="0">
912 Reads all pending bytes from the socket into a char* array which can be up to 16 kilobytes in length.
916 Definition at line <a class="el" href="socket_8cpp-source.html#l00155">155</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
918 References <a class="el" href="modules_8h-source.html#l00023">DEBUG</a>, and <a class="el" href="socket_8h-source.html#l00106">ibuf</a>.<div class="fragment"><pre class="fragment"><a name="l00156"></a>00156 {
919 <a name="l00157"></a>00157 <span class="keywordtype">int</span> n = recv(this->fd,this->ibuf,<span class="keyword">sizeof</span>(this->ibuf),0);
920 <a name="l00158"></a>00158 <span class="keywordflow">if</span> (n > 0)
921 <a name="l00159"></a>00159 {
922 <a name="l00160"></a>00160 <a class="code" href="classInspSocket.html#ibuf_5B_31_36_33_38_34_5D">ibuf</a>[n] = 0;
923 <a name="l00161"></a>00161 <span class="keywordflow">return</span> <a class="code" href="classInspSocket.html#ibuf_5B_31_36_33_38_34_5D">ibuf</a>;
924 <a name="l00162"></a>00162 }
925 <a name="l00163"></a>00163 <span class="keywordflow">else</span>
926 <a name="l00164"></a>00164 {
927 <a name="l00165"></a>00165 log(<a class="code" href="modules_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"EOF or error on socket"</span>);
928 <a name="l00166"></a>00166 <span class="keywordflow">return</span> NULL;
929 <a name="l00167"></a>00167 }
930 <a name="l00168"></a>00168 }
936 <a class="anchor" name="SetState_28InspSocketState_20s_29"></a><!-- doxytag: member="InspSocket::SetState" ref="SetState_28InspSocketState_20s_29" args="(InspSocketState s)" --><p>
937 <table class="mdTable" cellpadding="2" cellspacing="0">
940 <table cellpadding="0" cellspacing="0" border="0">
942 <td class="md" nowrap valign="top">void InspSocket::SetState </td>
943 <td class="md" valign="top">( </td>
944 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> </td>
945 <td class="mdname1" valign="top" nowrap> <em>s</em> </td>
946 <td class="md" valign="top"> ) </td>
947 <td class="md" nowrap></td>
953 <table cellspacing="5" cellpadding="0" border="0">
961 Changes the socket's state.
963 The core uses this to change socket states, and you should not call it directly.
965 Definition at line <a class="el" href="socket_8cpp-source.html#l00245">245</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
967 References <a class="el" href="modules_8h-source.html#l00023">DEBUG</a>, and <a class="el" href="socket_8h-source.html#l00072">state</a>.
969 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00246"></a>00246 {
970 <a name="l00247"></a>00247 log(<a class="code" href="modules_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"Socket state change"</span>);
971 <a name="l00248"></a>00248 this-><a class="code" href="classInspSocket.html#state">state</a> = s;
972 <a name="l00249"></a>00249 }
978 <a class="anchor" name="Timeout_28time_5Ft_20current_29"></a><!-- doxytag: member="InspSocket::Timeout" ref="Timeout_28time_5Ft_20current_29" args="(time_t current)" --><p>
979 <table class="mdTable" cellpadding="2" cellspacing="0">
982 <table cellpadding="0" cellspacing="0" border="0">
984 <td class="md" nowrap valign="top">bool InspSocket::Timeout </td>
985 <td class="md" valign="top">( </td>
986 <td class="md" nowrap valign="top">time_t </td>
987 <td class="mdname1" valign="top" nowrap> <em>current</em> </td>
988 <td class="md" valign="top"> ) </td>
989 <td class="md" nowrap></td>
995 <table cellspacing="5" cellpadding="0" border="0">
1003 This function checks if the socket has timed out yet, given the current time in the parameter.
1005 <dl compact><dt><b>Returns:</b></dt><dd>true if timed out, false if not timed out</dd></dl>
1008 Definition at line <a class="el" href="socket_8cpp-source.html#l00197">197</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
1010 References <a class="el" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>, <a class="el" href="socket_8h.html#InspSocketErrorI_5FERR_5FTIMEOUT">I_ERR_TIMEOUT</a>, <a class="el" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>, <a class="el" href="socket_8cpp-source.html#l00262">OnError()</a>, <a class="el" href="socket_8cpp-source.html#l00266">OnTimeout()</a>, <a class="el" href="socket_8h-source.html#l00072">state</a>, <a class="el" href="socket_8h-source.html#l00097">timeout</a>, and <a class="el" href="socket_8h-source.html#l00091">timeout_end</a>.<div class="fragment"><pre class="fragment"><a name="l00198"></a>00198 {
1011 <a name="l00199"></a>00199 <span class="keywordflow">if</span> ((this->state == <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>) && (current > <a class="code" href="classInspSocket.html#timeout_5Fend">timeout_end</a>))
1012 <a name="l00200"></a>00200 {
1013 <a name="l00201"></a>00201 <span class="comment">// for non-listening sockets, the timeout can occur</span>
1014 <a name="l00202"></a>00202 <span class="comment">// which causes termination of the connection after</span>
1015 <a name="l00203"></a>00203 <span class="comment">// the given number of seconds without a successful</span>
1016 <a name="l00204"></a>00204 <span class="comment">// connection.</span>
1017 <a name="l00205"></a>00205 this-><a class="code" href="classInspSocket.html#OnTimeout_28_29">OnTimeout</a>();
1018 <a name="l00206"></a>00206 this-><a class="code" href="classInspSocket.html#OnError_28InspSocketError_20e_29">OnError</a>(<a class="code" href="socket_8h.html#InspSocketErrorI_5FERR_5FTIMEOUT">I_ERR_TIMEOUT</a>);
1019 <a name="l00207"></a>00207 <a class="code" href="classInspSocket.html#timeout">timeout</a> = <span class="keyword">true</span>;
1020 <a name="l00208"></a>00208 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
1021 <a name="l00209"></a>00209 <span class="keywordflow">return</span> <span class="keyword">true</span>;
1022 <a name="l00210"></a>00210 }
1023 <a name="l00211"></a>00211 <span class="keywordflow">return</span> <span class="keyword">false</span>;
1024 <a name="l00212"></a>00212 }
1030 <a class="anchor" name="Write_28std_3A_3Astring_20data_29"></a><!-- doxytag: member="InspSocket::Write" ref="Write_28std_3A_3Astring_20data_29" args="(std::string data)" --><p>
1031 <table class="mdTable" cellpadding="2" cellspacing="0">
1034 <table cellpadding="0" cellspacing="0" border="0">
1036 <td class="md" nowrap valign="top">int InspSocket::Write </td>
1037 <td class="md" valign="top">( </td>
1038 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
1039 <td class="mdname1" valign="top" nowrap> <em>data</em> </td>
1040 <td class="md" valign="top"> ) </td>
1041 <td class="md" nowrap><code> [virtual]</code></td>
1047 <table cellspacing="5" cellpadding="0" border="0">
1055 Writes a <a class="el" href="namespaceirc.html#string">std::string</a> to the socket.
1057 No carriage returns or linefeeds are appended to the string. <dl compact><dt><b>Parameters:</b></dt><dd>
1058 <table border="0" cellspacing="2" cellpadding="0">
1059 <tr><td valign="top"></td><td valign="top"><em>data</em> </td><td>The data to send</td></tr>
1064 Definition at line <a class="el" href="socket_8cpp-source.html#l00174">174</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.<div class="fragment"><pre class="fragment"><a name="l00175"></a>00175 {
1065 <a name="l00176"></a>00176 <span class="keywordtype">char</span>* d = (<span class="keywordtype">char</span>*)data.c_str();
1066 <a name="l00177"></a>00177 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> written = 0;
1067 <a name="l00178"></a>00178 <span class="keywordtype">int</span> n = 0;
1068 <a name="l00179"></a>00179 <span class="keywordtype">int</span> s = data.length();
1069 <a name="l00180"></a>00180 <span class="keywordflow">while</span> ((written < data.length()) && (n >= 0))
1070 <a name="l00181"></a>00181 {
1071 <a name="l00182"></a>00182 n = send(this->fd,d,s,0);
1072 <a name="l00183"></a>00183 <span class="keywordflow">if</span> (n > 0)
1073 <a name="l00184"></a>00184 {
1074 <a name="l00185"></a>00185 <span class="comment">// If we didnt write everything, advance</span>
1075 <a name="l00186"></a>00186 <span class="comment">// the pointers so that when we retry</span>
1076 <a name="l00187"></a>00187 <span class="comment">// the next time around the loop, we try</span>
1077 <a name="l00188"></a>00188 <span class="comment">// to write what we failed to write before.</span>
1078 <a name="l00189"></a>00189 written += n;
1079 <a name="l00190"></a>00190 s -= n;
1080 <a name="l00191"></a>00191 d += n;
1081 <a name="l00192"></a>00192 }
1082 <a name="l00193"></a>00193 }
1083 <a name="l00194"></a>00194 <span class="keywordflow">return</span> written;
1084 <a name="l00195"></a>00195 }
1090 <hr><h2>Member Data Documentation</h2>
1091 <a class="anchor" name="addr"></a><!-- doxytag: member="InspSocket::addr" ref="addr" args="" --><p>
1092 <table class="mdTable" cellpadding="2" cellspacing="0">
1095 <table cellpadding="0" cellspacing="0" border="0">
1097 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#addr">InspSocket::addr</a><code> [private]</code> </td>
1103 <table cellspacing="5" cellpadding="0" border="0">
1111 The host being connected to, in sockaddr form.
1115 Definition at line <a class="el" href="socket_8h-source.html#l00078">78</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1117 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>. </td>
1120 <a class="anchor" name="addy"></a><!-- doxytag: member="InspSocket::addy" ref="addy" args="" --><p>
1121 <table class="mdTable" cellpadding="2" cellspacing="0">
1124 <table cellpadding="0" cellspacing="0" border="0">
1126 <td class="md" nowrap valign="top">in_addr <a class="el" href="classInspSocket.html#addy">InspSocket::addy</a><code> [private]</code> </td>
1132 <table cellspacing="5" cellpadding="0" border="0">
1140 The host being connected to, in in_addr form.
1144 Definition at line <a class="el" href="socket_8h-source.html#l00084">84</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1146 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>. </td>
1149 <a class="anchor" name="client"></a><!-- doxytag: member="InspSocket::client" ref="client" args="" --><p>
1150 <table class="mdTable" cellpadding="2" cellspacing="0">
1153 <table cellpadding="0" cellspacing="0" border="0">
1155 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#client">InspSocket::client</a><code> [private]</code> </td>
1161 <table cellspacing="5" cellpadding="0" border="0">
1169 Client sockaddr structure used by accept().
1173 Definition at line <a class="el" href="socket_8h-source.html#l00119">119</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1175 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>. </td>
1178 <a class="anchor" name="fd"></a><!-- doxytag: member="InspSocket::fd" ref="fd" args="" --><p>
1179 <table class="mdTable" cellpadding="2" cellspacing="0">
1182 <table cellpadding="0" cellspacing="0" border="0">
1184 <td class="md" nowrap valign="top">int <a class="el" href="classInspSocket.html#fd">InspSocket::fd</a><code> [private]</code> </td>
1190 <table cellspacing="5" cellpadding="0" border="0">
1198 The file descriptor of this socket.
1202 Definition at line <a class="el" href="socket_8h-source.html#l00054">54</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1204 Referenced by <a class="el" href="socket_8cpp-source.html#l00139">Close()</a>, <a class="el" href="socket_8cpp-source.html#l00256">GetFd()</a>, and <a class="el" href="socket_8cpp-source.html#l00054">InspSocket()</a>. </td>
1207 <a class="anchor" name="host"></a><!-- doxytag: member="InspSocket::host" ref="host" args="" --><p>
1208 <table class="mdTable" cellpadding="2" cellspacing="0">
1211 <table cellpadding="0" cellspacing="0" border="0">
1213 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> <a class="el" href="classInspSocket.html#host">InspSocket::host</a><code> [private]</code> </td>
1219 <table cellspacing="5" cellpadding="0" border="0">
1227 The hostname connected to.
1231 Definition at line <a class="el" href="socket_8h-source.html#l00059">59</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>. </td>
1234 <a class="anchor" name="ibuf_5B_31_36_33_38_34_5D"></a><!-- doxytag: member="InspSocket::ibuf" ref="ibuf_5B_31_36_33_38_34_5D" args="[16384]" --><p>
1235 <table class="mdTable" cellpadding="2" cellspacing="0">
1238 <table cellpadding="0" cellspacing="0" border="0">
1240 <td class="md" nowrap valign="top">char <a class="el" href="classInspSocket.html#ibuf_5B_31_36_33_38_34_5D">InspSocket::ibuf</a>[16384]<code> [private]</code> </td>
1246 <table cellspacing="5" cellpadding="0" border="0">
1254 Socket input buffer, used by read().
1256 The class which extends InspSocket is expected to implement an extendable buffer which can grow much larger than 16k, this buffer is just designed to be temporary storage. space.
1258 Definition at line <a class="el" href="socket_8h-source.html#l00106">106</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1260 Referenced by <a class="el" href="socket_8cpp-source.html#l00155">Read()</a>. </td>
1263 <a class="anchor" name="IP"></a><!-- doxytag: member="InspSocket::IP" ref="IP" args="" --><p>
1264 <table class="mdTable" cellpadding="2" cellspacing="0">
1267 <table cellpadding="0" cellspacing="0" border="0">
1269 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> <a class="el" href="classInspSocket.html#IP">InspSocket::IP</a><code> [private]</code> </td>
1275 <table cellspacing="5" cellpadding="0" border="0">
1283 The IP address being connected to stored in string form for easy retrieval by accessors.
1287 Definition at line <a class="el" href="socket_8h-source.html#l00113">113</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1289 Referenced by <a class="el" href="socket_8cpp-source.html#l00150">GetIP()</a>, and <a class="el" href="socket_8cpp-source.html#l00054">InspSocket()</a>. </td>
1292 <a class="anchor" name="length"></a><!-- doxytag: member="InspSocket::length" ref="length" args="" --><p>
1293 <table class="mdTable" cellpadding="2" cellspacing="0">
1296 <table cellpadding="0" cellspacing="0" border="0">
1298 <td class="md" nowrap valign="top">socklen_t <a class="el" href="classInspSocket.html#length">InspSocket::length</a><code> [private]</code> </td>
1304 <table cellspacing="5" cellpadding="0" border="0">
1312 Used by accept() to indicate the sizes of the sockaddr_in structures.
1316 Definition at line <a class="el" href="socket_8h-source.html#l00131">131</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1318 Referenced by <a class="el" href="socket_8cpp-source.html#l00214">Poll()</a>. </td>
1321 <a class="anchor" name="port"></a><!-- doxytag: member="InspSocket::port" ref="port" args="" --><p>
1322 <table class="mdTable" cellpadding="2" cellspacing="0">
1325 <table cellpadding="0" cellspacing="0" border="0">
1327 <td class="md" nowrap valign="top">int <a class="el" href="classInspSocket.html#port">InspSocket::port</a><code> [private]</code> </td>
1333 <table cellspacing="5" cellpadding="0" border="0">
1341 The port connected to, or the port this socket is listening on.
1345 Definition at line <a class="el" href="socket_8h-source.html#l00065">65</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>. </td>
1348 <a class="anchor" name="server"></a><!-- doxytag: member="InspSocket::server" ref="server" args="" --><p>
1349 <table class="mdTable" cellpadding="2" cellspacing="0">
1352 <table cellpadding="0" cellspacing="0" border="0">
1354 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#server">InspSocket::server</a><code> [private]</code> </td>
1360 <table cellspacing="5" cellpadding="0" border="0">
1368 <a class="el" href="classServer.html">Server</a> sockaddr structure used by accept().
1372 Definition at line <a class="el" href="socket_8h-source.html#l00125">125</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>. </td>
1375 <a class="anchor" name="state"></a><!-- doxytag: member="InspSocket::state" ref="state" args="" --><p>
1376 <table class="mdTable" cellpadding="2" cellspacing="0">
1379 <table cellpadding="0" cellspacing="0" border="0">
1381 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> <a class="el" href="classInspSocket.html#state">InspSocket::state</a><code> [private]</code> </td>
1387 <table cellspacing="5" cellpadding="0" border="0">
1395 The state for this socket, either listening, connecting, connected or error.
1399 Definition at line <a class="el" href="socket_8h-source.html#l00072">72</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1401 Referenced by <a class="el" href="socket_8cpp-source.html#l00251">GetState()</a>, <a class="el" href="socket_8cpp-source.html#l00049">InspSocket()</a>, <a class="el" href="socket_8cpp-source.html#l00245">SetState()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1404 <a class="anchor" name="timeout"></a><!-- doxytag: member="InspSocket::timeout" ref="timeout" args="" --><p>
1405 <table class="mdTable" cellpadding="2" cellspacing="0">
1408 <table cellpadding="0" cellspacing="0" border="0">
1410 <td class="md" nowrap valign="top">bool <a class="el" href="classInspSocket.html#timeout">InspSocket::timeout</a><code> [private]</code> </td>
1416 <table cellspacing="5" cellpadding="0" border="0">
1424 This value is true if the socket has timed out.
1428 Definition at line <a class="el" href="socket_8h-source.html#l00097">97</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1430 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1433 <a class="anchor" name="timeout_5Fend"></a><!-- doxytag: member="InspSocket::timeout_end" ref="timeout_5Fend" args="" --><p>
1434 <table class="mdTable" cellpadding="2" cellspacing="0">
1437 <table cellpadding="0" cellspacing="0" border="0">
1439 <td class="md" nowrap valign="top">time_t <a class="el" href="classInspSocket.html#timeout_5Fend">InspSocket::timeout_end</a><code> [private]</code> </td>
1445 <table cellspacing="5" cellpadding="0" border="0">
1453 When this time is reached, the socket times out if it is in the CONNECTING state.
1457 Definition at line <a class="el" href="socket_8h-source.html#l00091">91</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1459 Referenced by <a class="el" href="socket_8cpp-source.html#l00062">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1462 <hr>The documentation for this class was generated from the following files:<ul>
1463 <li><a class="el" href="socket_8h-source.html">socket.h</a><li><a class="el" href="socket_8cpp-source.html">socket.cpp</a></ul>
1464 <hr size="1"><address style="align: right;"><small>Generated on Mon Dec 12 18:31:02 2005 for InspIRCd by
1465 <a href="http://www.doxygen.org/index.html">
1466 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4-20050815 </small></address>