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 Member Functions</h2></td></tr>
78 <tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#FlushWriteBuffer_28_29">FlushWriteBuffer</a> ()</td></tr>
80 <tr><td class="mdescLeft"> </td><td class="mdescRight">Flushes the write buffer. <a href="#FlushWriteBuffer_28_29"></a><br></td></tr>
81 <tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
82 <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>
84 <tr><td class="mdescLeft"> </td><td class="mdescRight">The file descriptor of this socket. <a href="#fd"></a><br></td></tr>
85 <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>
87 <tr><td class="mdescLeft"> </td><td class="mdescRight">The hostname connected to. <a href="#host"></a><br></td></tr>
88 <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>
90 <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>
91 <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>
93 <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>
94 <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>
96 <tr><td class="mdescLeft"> </td><td class="mdescRight">The host being connected to, in sockaddr form. <a href="#addr"></a><br></td></tr>
97 <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>
99 <tr><td class="mdescLeft"> </td><td class="mdescRight">The host being connected to, in in_addr form. <a href="#addy"></a><br></td></tr>
100 <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>
102 <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>
103 <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>
105 <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>
106 <tr><td class="memItemLeft" nowrap align="right" valign="top">char </td><td class="memItemRight" valign="bottom"><a class="el" href="classInspSocket.html#ibuf_5B_36_35_35_33_35_5D">ibuf</a> [65535]</td></tr>
108 <tr><td class="mdescLeft"> </td><td class="mdescRight">Socket input buffer, used by read(). <a href="#ibuf_5B_36_35_35_33_35_5D"></a><br></td></tr>
109 <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#Buffer">Buffer</a></td></tr>
111 <tr><td class="mdescLeft"> </td><td class="mdescRight">The output buffer for this socket. <a href="#Buffer"></a><br></td></tr>
112 <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>
114 <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>
115 <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>
117 <tr><td class="mdescLeft"> </td><td class="mdescRight">Client sockaddr structure used by accept(). <a href="#client"></a><br></td></tr>
118 <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>
120 <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>
121 <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>
123 <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>
125 <hr><a name="_details"></a><h2>Detailed Description</h2>
126 InspSocket is an extendable socket class which modules can use for TCP socket support.
128 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.
132 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>
133 <a class="anchor" name="InspSocket_28_29"></a><!-- doxytag: member="InspSocket::InspSocket" ref="InspSocket_28_29" args="()" --><p>
134 <table class="mdTable" cellpadding="2" cellspacing="0">
137 <table cellpadding="0" cellspacing="0" border="0">
139 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
140 <td class="md" valign="top">( </td>
141 <td class="mdname1" valign="top" nowrap> </td>
142 <td class="md" valign="top"> ) </td>
143 <td class="md" nowrap></td>
149 <table cellspacing="5" cellpadding="0" border="0">
157 The default constructor does nothing and should not be used.
161 Definition at line <a class="el" href="socket_8cpp-source.html#l00045">45</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
163 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="l00046"></a>00046 {
164 <a name="l00047"></a>00047 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FDISCONNECTED">I_DISCONNECTED</a>;
165 <a name="l00048"></a>00048 }
171 <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>
172 <table class="mdTable" cellpadding="2" cellspacing="0">
175 <table cellpadding="0" cellspacing="0" border="0">
177 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
178 <td class="md" valign="top">( </td>
179 <td class="md" nowrap valign="top">int </td>
180 <td class="mdname" nowrap> <em>newfd</em>, </td>
183 <td class="md" nowrap align="right"></td>
185 <td class="md" nowrap>char * </td>
186 <td class="mdname" nowrap> <em>ip</em></td>
190 <td class="md">) </td>
191 <td class="md" colspan="2"></td>
197 <table cellspacing="5" cellpadding="0" border="0">
205 This constructor is used to associate an existing connecting with an InspSocket class.
207 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.
209 Definition at line <a class="el" href="socket_8cpp-source.html#l00050">50</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
211 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#l00118">IP</a>, <a class="el" href="inspircd_8h-source.html#l00111">InspIRCd::SE</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="l00051"></a>00051 {
212 <a name="l00052"></a>00052 this-><a class="code" href="classInspSocket.html#fd">fd</a> = newfd;
213 <a name="l00053"></a>00053 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>;
214 <a name="l00054"></a>00054 this-><a class="code" href="classInspSocket.html#IP">IP</a> = ip;
215 <a name="l00055"></a>00055 <a class="code" href="modules_8cpp.html#ServerInstance">ServerInstance</a>-><a class="code" href="classInspIRCd.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>);
216 <a name="l00056"></a>00056 <a class="code" href="socket_8cpp.html#socket_5Fref_5B_36_35_35_33_35_5D">socket_ref</a>[this-><a class="code" href="classInspSocket.html#fd">fd</a>] = <span class="keyword">this</span>;
217 <a name="l00057"></a>00057 }
223 <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>
224 <table class="mdTable" cellpadding="2" cellspacing="0">
227 <table cellpadding="0" cellspacing="0" border="0">
229 <td class="md" nowrap valign="top">InspSocket::InspSocket </td>
230 <td class="md" valign="top">( </td>
231 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
232 <td class="mdname" nowrap> <em>host</em>, </td>
235 <td class="md" nowrap align="right"></td>
237 <td class="md" nowrap>int </td>
238 <td class="mdname" nowrap> <em>port</em>, </td>
241 <td class="md" nowrap align="right"></td>
243 <td class="md" nowrap>bool </td>
244 <td class="mdname" nowrap> <em>listening</em>, </td>
247 <td class="md" nowrap align="right"></td>
249 <td class="md" nowrap>unsigned long </td>
250 <td class="mdname" nowrap> <em>maxtime</em></td>
254 <td class="md">) </td>
255 <td class="md" colspan="2"></td>
261 <table cellspacing="5" cellpadding="0" border="0">
269 This constructor is used to create a new socket, either listening for connections, or an outbound connection to another host.
271 <dl compact><dt><b>Parameters:</b></dt><dd>
272 <table border="0" cellspacing="2" cellpadding="0">
273 <tr><td valign="top"></td><td valign="top"><em>host</em> </td><td>The hostname to connect to, or bind to </td></tr>
274 <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>The port number to connect to, or bind to </td></tr>
275 <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>
276 <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>
281 Definition at line <a class="el" href="socket_8cpp-source.html#l00059">59</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
283 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="inspircd__io_8h.html#BindSocket_28int_20sockfd_2C_20struct_20sockaddr_5Fin_20client_2C_20struct_20sockaddr_5Fin_20server_2C_20int_20port_2C_20char_20_2Aaddr_29">BindSocket()</a>, <a class="el" href="socket_8cpp-source.html#l00138">Close()</a>, <a class="el" href="inspircd__io_8h-source.html#l00029">DEBUG</a>, <a class="el" href="inspircd_8h-source.html#l00051">ERROR</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#l00118">IP</a>, <a class="el" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log()</a>, <a class="el" href="socket_8cpp-source.html#l00264">OnError()</a>, <a class="el" href="inspircd__io_8h.html#OpenTCPSocket_28void_29">OpenTCPSocket()</a>, <a class="el" href="inspircd_8h-source.html#l00111">InspIRCd::SE</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="l00060"></a>00060 {
284 <a name="l00061"></a>00061 <span class="keywordflow">if</span> (listening) {
285 <a name="l00062"></a>00062 <span class="keywordflow">if</span> ((this->fd = <a class="code" href="inspircd__io_8h.html#OpenTCPSocket_28void_29">OpenTCPSocket</a>()) == <a class="code" href="inspircd_8h.html#ERROR">ERROR</a>)
286 <a name="l00063"></a>00063 {
287 <a name="l00064"></a>00064 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
288 <a name="l00065"></a>00065 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
289 <a name="l00066"></a>00066 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>);
290 <a name="l00067"></a>00067 <a class="code" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log</a>(<a class="code" href="inspircd__io_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"OpenTCPSocket() error"</span>);
291 <a name="l00068"></a>00068 <span class="keywordflow">return</span>;
292 <a name="l00069"></a>00069 }
293 <a name="l00070"></a>00070 <span class="keywordflow">else</span>
294 <a name="l00071"></a>00071 {
295 <a name="l00072"></a>00072 <span class="keywordflow">if</span> (<a class="code" href="inspircd__io_8h.html#BindSocket_28int_20sockfd_2C_20struct_20sockaddr_5Fin_20client_2C_20struct_20sockaddr_5Fin_20server_2C_20int_20port_2C_20char_20_2Aaddr_29">BindSocket</a>(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()) == <a class="code" href="inspircd_8h.html#ERROR">ERROR</a>)
296 <a name="l00073"></a>00073 {
297 <a name="l00074"></a>00074 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
298 <a name="l00075"></a>00075 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
299 <a name="l00076"></a>00076 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
300 <a name="l00077"></a>00077 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>);
301 <a name="l00078"></a>00078 <a class="code" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log</a>(<a class="code" href="inspircd__io_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"BindSocket() error %s"</span>,strerror(errno));
302 <a name="l00079"></a>00079 <span class="keywordflow">return</span>;
303 <a name="l00080"></a>00080 }
304 <a name="l00081"></a>00081 <span class="keywordflow">else</span>
305 <a name="l00082"></a>00082 {
306 <a name="l00083"></a>00083 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>;
307 <a name="l00084"></a>00084 <a class="code" href="modules_8cpp.html#ServerInstance">ServerInstance</a>-><a class="code" href="classInspIRCd.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>);
308 <a name="l00085"></a>00085 <a class="code" href="socket_8cpp.html#socket_5Fref_5B_36_35_35_33_35_5D">socket_ref</a>[this-><a class="code" href="classInspSocket.html#fd">fd</a>] = <span class="keyword">this</span>;
309 <a name="l00086"></a>00086 <a class="code" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log</a>(<a class="code" href="inspircd__io_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"New socket now in I_LISTENING state"</span>);
310 <a name="l00087"></a>00087 <span class="keywordflow">return</span>;
311 <a name="l00088"></a>00088 }
312 <a name="l00089"></a>00089 }
313 <a name="l00090"></a>00090 } <span class="keywordflow">else</span> {
314 <a name="l00091"></a>00091 <span class="keywordtype">char</span>* ip;
315 <a name="l00092"></a>00092 this-><a class="code" href="classInspSocket.html#host">host</a> = <a class="code" href="classInspSocket.html#host">host</a>;
316 <a name="l00093"></a>00093 hostent* hoste = gethostbyname(<a class="code" href="classInspSocket.html#host">host</a>.c_str());
317 <a name="l00094"></a>00094 <span class="keywordflow">if</span> (!hoste) {
318 <a name="l00095"></a>00095 ip = (<span class="keywordtype">char</span>*)<a class="code" href="classInspSocket.html#host">host</a>.c_str();
319 <a name="l00096"></a>00096 } <span class="keywordflow">else</span> {
320 <a name="l00097"></a>00097 <span class="keyword">struct </span>in_addr* ia = (in_addr*)hoste->h_addr;
321 <a name="l00098"></a>00098 ip = inet_ntoa(*ia);
322 <a name="l00099"></a>00099 }
323 <a name="l00100"></a>00100
324 <a name="l00101"></a>00101 this-><a class="code" href="classInspSocket.html#IP">IP</a> = ip;
325 <a name="l00102"></a>00102
326 <a name="l00103"></a>00103 <a class="code" href="classInspSocket.html#timeout_5Fend">timeout_end</a> = time(NULL)+maxtime;
327 <a name="l00104"></a>00104 <a class="code" href="classInspSocket.html#timeout">timeout</a> = <span class="keyword">false</span>;
328 <a name="l00105"></a>00105 <span class="keywordflow">if</span> ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
329 <a name="l00106"></a>00106 {
330 <a name="l00107"></a>00107 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
331 <a name="l00108"></a>00108 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>);
332 <a name="l00109"></a>00109 <span class="keywordflow">return</span>;
333 <a name="l00110"></a>00110 }
334 <a name="l00111"></a>00111 this-><a class="code" href="classInspSocket.html#port">port</a> = <a class="code" href="classInspSocket.html#port">port</a>;
335 <a name="l00112"></a>00112 inet_aton(ip,&<a class="code" href="classInspSocket.html#addy">addy</a>);
336 <a name="l00113"></a>00113 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_family = AF_INET;
337 <a name="l00114"></a>00114 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_addr = <a class="code" href="classInspSocket.html#addy">addy</a>;
338 <a name="l00115"></a>00115 <a class="code" href="classInspSocket.html#addr">addr</a>.sin_port = htons(this->port);
339 <a name="l00116"></a>00116
340 <a name="l00117"></a>00117 <span class="keywordtype">int</span> flags;
341 <a name="l00118"></a>00118 flags = fcntl(this->fd, F_GETFL, 0);
342 <a name="l00119"></a>00119 fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
343 <a name="l00120"></a>00120
344 <a name="l00121"></a>00121 <span class="keywordflow">if</span>(connect(this->fd, (sockaddr*)&this->addr,<span class="keyword">sizeof</span>(this->addr)) == -1)
345 <a name="l00122"></a>00122 {
346 <a name="l00123"></a>00123 <span class="keywordflow">if</span> (errno != EINPROGRESS)
347 <a name="l00124"></a>00124 {
348 <a name="l00125"></a>00125 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
349 <a name="l00126"></a>00126 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>);
350 <a name="l00127"></a>00127 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FERROR">I_ERROR</a>;
351 <a name="l00128"></a>00128 <span class="keywordflow">return</span>;
352 <a name="l00129"></a>00129 }
353 <a name="l00130"></a>00130 }
354 <a name="l00131"></a>00131 this-><a class="code" href="classInspSocket.html#state">state</a> = <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>;
355 <a name="l00132"></a>00132 <a class="code" href="modules_8cpp.html#ServerInstance">ServerInstance</a>-><a class="code" href="classInspIRCd.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>);
356 <a name="l00133"></a>00133 <a class="code" href="socket_8cpp.html#socket_5Fref_5B_36_35_35_33_35_5D">socket_ref</a>[this-><a class="code" href="classInspSocket.html#fd">fd</a>] = <span class="keyword">this</span>;
357 <a name="l00134"></a>00134 <span class="keywordflow">return</span>;
358 <a name="l00135"></a>00135 }
359 <a name="l00136"></a>00136 }
365 <a class="anchor" name="_7EInspSocket_28_29"></a><!-- doxytag: member="InspSocket::~InspSocket" ref="_7EInspSocket_28_29" args="()" --><p>
366 <table class="mdTable" cellpadding="2" cellspacing="0">
369 <table cellpadding="0" cellspacing="0" border="0">
371 <td class="md" nowrap valign="top">InspSocket::~InspSocket </td>
372 <td class="md" valign="top">( </td>
373 <td class="mdname1" valign="top" nowrap> </td>
374 <td class="md" valign="top"> ) </td>
375 <td class="md" nowrap><code> [virtual]</code></td>
381 <table cellspacing="5" cellpadding="0" border="0">
389 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.
393 Definition at line <a class="el" href="socket_8cpp-source.html#l00271">271</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
395 References <a class="el" href="socket_8cpp-source.html#l00138">Close()</a>.<div class="fragment"><pre class="fragment"><a name="l00272"></a>00272 {
396 <a name="l00273"></a>00273 this-><a class="code" href="classInspSocket.html#Close_28_29">Close</a>();
397 <a name="l00274"></a>00274 }
403 <hr><h2>Member Function Documentation</h2>
404 <a class="anchor" name="Close_28_29"></a><!-- doxytag: member="InspSocket::Close" ref="Close_28_29" args="()" --><p>
405 <table class="mdTable" cellpadding="2" cellspacing="0">
408 <table cellpadding="0" cellspacing="0" border="0">
410 <td class="md" nowrap valign="top">void InspSocket::Close </td>
411 <td class="md" valign="top">( </td>
412 <td class="mdname1" valign="top" nowrap> </td>
413 <td class="md" valign="top"> ) </td>
414 <td class="md" nowrap><code> [virtual]</code></td>
420 <table cellspacing="5" cellpadding="0" border="0">
428 This method causes the socket to close, and may also be triggered by other methods such as OnTimeout and OnError.
432 Definition at line <a class="el" href="socket_8cpp-source.html#l00138">138</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
434 References <a class="el" href="socket_8h-source.html#l00054">fd</a>, and <a class="el" href="socket_8cpp-source.html#l00269">OnClose()</a>.
436 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00271">~InspSocket()</a>.<div class="fragment"><pre class="fragment"><a name="l00139"></a>00139 {
437 <a name="l00140"></a>00140 <span class="keywordflow">if</span> (this->fd != -1)
438 <a name="l00141"></a>00141 {
439 <a name="l00142"></a>00142 this-><a class="code" href="classInspSocket.html#OnClose_28_29">OnClose</a>();
440 <a name="l00143"></a>00143 shutdown(this->fd,2);
441 <a name="l00144"></a>00144 close(this->fd);
442 <a name="l00145"></a>00145 <a class="code" href="socket_8cpp.html#socket_5Fref_5B_36_35_35_33_35_5D">socket_ref</a>[this-><a class="code" href="classInspSocket.html#fd">fd</a>] = NULL;
443 <a name="l00146"></a>00146 this-><a class="code" href="classInspSocket.html#fd">fd</a> = -1;
444 <a name="l00147"></a>00147 }
445 <a name="l00148"></a>00148 }
451 <a class="anchor" name="FlushWriteBuffer_28_29"></a><!-- doxytag: member="InspSocket::FlushWriteBuffer" ref="FlushWriteBuffer_28_29" args="()" --><p>
452 <table class="mdTable" cellpadding="2" cellspacing="0">
455 <table cellpadding="0" cellspacing="0" border="0">
457 <td class="md" nowrap valign="top">void InspSocket::FlushWriteBuffer </td>
458 <td class="md" valign="top">( </td>
459 <td class="mdname1" valign="top" nowrap> </td>
460 <td class="md" valign="top"> ) </td>
461 <td class="md" nowrap><code> [private]</code></td>
467 <table cellspacing="5" cellpadding="0" border="0">
475 Flushes the write buffer.
479 Definition at line <a class="el" href="socket_8cpp-source.html#l00181">181</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
481 References <a class="el" href="socket_8h-source.html#l00111">Buffer</a>.
483 Referenced by <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>, and <a class="el" href="socket_8cpp-source.html#l00174">Write()</a>.<div class="fragment"><pre class="fragment"><a name="l00182"></a>00182 {
484 <a name="l00183"></a>00183 <span class="keywordtype">int</span> result = 0;
485 <a name="l00184"></a>00184 <span class="keywordflow">if</span> (this->Buffer.length())
486 <a name="l00185"></a>00185 {
487 <a name="l00186"></a>00186 result = send(this->fd,this->Buffer.c_str(),this-><a class="code" href="classInspSocket.html#Buffer">Buffer</a>.length(),0);
488 <a name="l00187"></a>00187 <span class="keywordflow">if</span> (result > 0)
489 <a name="l00188"></a>00188 {
490 <a name="l00189"></a>00189 <span class="comment">/* If we wrote some, advance the buffer forwards */</span>
491 <a name="l00190"></a>00190 <span class="keywordtype">char</span>* n = (<span class="keywordtype">char</span>*)this-><a class="code" href="classInspSocket.html#Buffer">Buffer</a>.c_str();
492 <a name="l00191"></a>00191 n += result;
493 <a name="l00192"></a>00192 this-><a class="code" href="classInspSocket.html#Buffer">Buffer</a> = n;
494 <a name="l00193"></a>00193 }
495 <a name="l00194"></a>00194 }
496 <a name="l00195"></a>00195 }
502 <a class="anchor" name="GetFd_28_29"></a><!-- doxytag: member="InspSocket::GetFd" ref="GetFd_28_29" args="()" --><p>
503 <table class="mdTable" cellpadding="2" cellspacing="0">
506 <table cellpadding="0" cellspacing="0" border="0">
508 <td class="md" nowrap valign="top">int InspSocket::GetFd </td>
509 <td class="md" valign="top">( </td>
510 <td class="mdname1" valign="top" nowrap> </td>
511 <td class="md" valign="top"> ) </td>
512 <td class="md" nowrap></td>
518 <table cellspacing="5" cellpadding="0" border="0">
526 This method returns the socket's file descriptor as assigned by the operating system, or -1 if no descriptor has been assigned.
530 Definition at line <a class="el" href="socket_8cpp-source.html#l00258">258</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
532 References <a class="el" href="socket_8h-source.html#l00054">fd</a>.<div class="fragment"><pre class="fragment"><a name="l00259"></a>00259 {
533 <a name="l00260"></a>00260 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#fd">fd</a>;
534 <a name="l00261"></a>00261 }
540 <a class="anchor" name="GetIP_28_29"></a><!-- doxytag: member="InspSocket::GetIP" ref="GetIP_28_29" args="()" --><p>
541 <table class="mdTable" cellpadding="2" cellspacing="0">
544 <table cellpadding="0" cellspacing="0" border="0">
546 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> InspSocket::GetIP </td>
547 <td class="md" valign="top">( </td>
548 <td class="mdname1" valign="top" nowrap> </td>
549 <td class="md" valign="top"> ) </td>
550 <td class="md" nowrap></td>
556 <table cellspacing="5" cellpadding="0" border="0">
564 Returns the IP address associated with this connection, or an empty string if no IP address exists.
568 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>.
570 References <a class="el" href="socket_8h-source.html#l00118">IP</a>.<div class="fragment"><pre class="fragment"><a name="l00151"></a>00151 {
571 <a name="l00152"></a>00152 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#IP">IP</a>;
572 <a name="l00153"></a>00153 }
578 <a class="anchor" name="GetState_28_29"></a><!-- doxytag: member="InspSocket::GetState" ref="GetState_28_29" args="()" --><p>
579 <table class="mdTable" cellpadding="2" cellspacing="0">
582 <table cellpadding="0" cellspacing="0" border="0">
584 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> InspSocket::GetState </td>
585 <td class="md" valign="top">( </td>
586 <td class="mdname1" valign="top" nowrap> </td>
587 <td class="md" valign="top"> ) </td>
588 <td class="md" nowrap></td>
594 <table cellspacing="5" cellpadding="0" border="0">
602 Returns the current socket state.
606 Definition at line <a class="el" href="socket_8cpp-source.html#l00253">253</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
608 References <a class="el" href="socket_8h-source.html#l00072">state</a>.<div class="fragment"><pre class="fragment"><a name="l00254"></a>00254 {
609 <a name="l00255"></a>00255 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#state">state</a>;
610 <a name="l00256"></a>00256 }
616 <a class="anchor" name="OnClose_28_29"></a><!-- doxytag: member="InspSocket::OnClose" ref="OnClose_28_29" args="()" --><p>
617 <table class="mdTable" cellpadding="2" cellspacing="0">
620 <table cellpadding="0" cellspacing="0" border="0">
622 <td class="md" nowrap valign="top">void InspSocket::OnClose </td>
623 <td class="md" valign="top">( </td>
624 <td class="mdname1" valign="top" nowrap> </td>
625 <td class="md" valign="top"> ) </td>
626 <td class="md" nowrap><code> [virtual]</code></td>
632 <table cellspacing="5" cellpadding="0" border="0">
640 Whenever close() is called, <a class="el" href="classInspSocket.html#OnClose_28_29">OnClose()</a> will be called first.
642 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.
644 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>.
646 Referenced by <a class="el" href="socket_8cpp-source.html#l00138">Close()</a>.<div class="fragment"><pre class="fragment"><a name="l00269"></a>00269 { <span class="keywordflow">return</span>; }
652 <a class="anchor" name="OnConnected_28_29"></a><!-- doxytag: member="InspSocket::OnConnected" ref="OnConnected_28_29" args="()" --><p>
653 <table class="mdTable" cellpadding="2" cellspacing="0">
656 <table cellpadding="0" cellspacing="0" border="0">
658 <td class="md" nowrap valign="top">bool InspSocket::OnConnected </td>
659 <td class="md" valign="top">( </td>
660 <td class="mdname1" valign="top" nowrap> </td>
661 <td class="md" valign="top"> ) </td>
662 <td class="md" nowrap><code> [virtual]</code></td>
668 <table cellspacing="5" cellpadding="0" border="0">
676 This method is called when an outbound connection on your socket is completed.
678 <dl compact><dt><b>Returns:</b></dt><dd>false to abort the connection, true to continue</dd></dl>
681 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>.
683 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00263"></a>00263 { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
689 <a class="anchor" name="OnDataReady_28_29"></a><!-- doxytag: member="InspSocket::OnDataReady" ref="OnDataReady_28_29" args="()" --><p>
690 <table class="mdTable" cellpadding="2" cellspacing="0">
693 <table cellpadding="0" cellspacing="0" border="0">
695 <td class="md" nowrap valign="top">bool InspSocket::OnDataReady </td>
696 <td class="md" valign="top">( </td>
697 <td class="mdname1" valign="top" nowrap> </td>
698 <td class="md" valign="top"> ) </td>
699 <td class="md" nowrap><code> [virtual]</code></td>
705 <table cellspacing="5" cellpadding="0" border="0">
713 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.
715 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>
718 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>.
720 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00267"></a>00267 { <span class="keywordflow">return</span> <span class="keyword">true</span>; }
726 <a class="anchor" name="OnDisconnect_28_29"></a><!-- doxytag: member="InspSocket::OnDisconnect" ref="OnDisconnect_28_29" args="()" --><p>
727 <table class="mdTable" cellpadding="2" cellspacing="0">
730 <table cellpadding="0" cellspacing="0" border="0">
732 <td class="md" nowrap valign="top">int InspSocket::OnDisconnect </td>
733 <td class="md" valign="top">( </td>
734 <td class="mdname1" valign="top" nowrap> </td>
735 <td class="md" valign="top"> ) </td>
736 <td class="md" nowrap><code> [virtual]</code></td>
742 <table cellspacing="5" cellpadding="0" border="0">
750 When an established connection is terminated, the OnDisconnect method is triggered.
754 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>.<div class="fragment"><pre class="fragment"><a name="l00265"></a>00265 { <span class="keywordflow">return</span> 0; }
760 <a class="anchor" name="OnError_28InspSocketError_20e_29"></a><!-- doxytag: member="InspSocket::OnError" ref="OnError_28InspSocketError_20e_29" args="(InspSocketError e)" --><p>
761 <table class="mdTable" cellpadding="2" cellspacing="0">
764 <table cellpadding="0" cellspacing="0" border="0">
766 <td class="md" nowrap valign="top">void InspSocket::OnError </td>
767 <td class="md" valign="top">( </td>
768 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketError">InspSocketError</a> </td>
769 <td class="mdname1" valign="top" nowrap> <em>e</em> </td>
770 <td class="md" valign="top"> ) </td>
771 <td class="md" nowrap><code> [virtual]</code></td>
777 <table cellspacing="5" cellpadding="0" border="0">
785 This method is called when an error occurs.
787 A closed socket in itself is not an error, however errors also generate close events. <dl compact><dt><b>Parameters:</b></dt><dd>
788 <table border="0" cellspacing="2" cellpadding="0">
789 <tr><td valign="top"></td><td valign="top"><em>e</em> </td><td>The error type which occured</td></tr>
794 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>.
796 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>.<div class="fragment"><pre class="fragment"><a name="l00264"></a>00264 { <span class="keywordflow">return</span>; }
802 <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>
803 <table class="mdTable" cellpadding="2" cellspacing="0">
806 <table cellpadding="0" cellspacing="0" border="0">
808 <td class="md" nowrap valign="top">int InspSocket::OnIncomingConnection </td>
809 <td class="md" valign="top">( </td>
810 <td class="md" nowrap valign="top">int </td>
811 <td class="mdname" nowrap> <em>newfd</em>, </td>
814 <td class="md" nowrap align="right"></td>
816 <td class="md" nowrap>char * </td>
817 <td class="mdname" nowrap> <em>ip</em></td>
821 <td class="md">) </td>
822 <td class="md" colspan="2"><code> [virtual]</code></td>
828 <table cellspacing="5" cellpadding="0" border="0">
836 If your socket is a listening socket, when a new connection comes in on the socket this method will be called.
838 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>
839 MySocket* newsocket = new MySocket(newfd,ip);<p>
840 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>.
842 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>.
844 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00266"></a>00266 { <span class="keywordflow">return</span> 0; }
850 <a class="anchor" name="OnTimeout_28_29"></a><!-- doxytag: member="InspSocket::OnTimeout" ref="OnTimeout_28_29" args="()" --><p>
851 <table class="mdTable" cellpadding="2" cellspacing="0">
854 <table cellpadding="0" cellspacing="0" border="0">
856 <td class="md" nowrap valign="top">void InspSocket::OnTimeout </td>
857 <td class="md" valign="top">( </td>
858 <td class="mdname1" valign="top" nowrap> </td>
859 <td class="md" valign="top"> ) </td>
860 <td class="md" nowrap><code> [virtual]</code></td>
866 <table cellspacing="5" cellpadding="0" border="0">
874 When an outbound connection fails, and the attempt times out, you will receive this event.
876 The mthod will trigger once maxtime secons are reached (as given in the constructor) just before the socket's descriptor is closed.
878 Definition at line <a class="el" href="socket_8cpp-source.html#l00268">268</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
880 Referenced by <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>.<div class="fragment"><pre class="fragment"><a name="l00268"></a>00268 { <span class="keywordflow">return</span>; }
886 <a class="anchor" name="Poll_28_29"></a><!-- doxytag: member="InspSocket::Poll" ref="Poll_28_29" args="()" --><p>
887 <table class="mdTable" cellpadding="2" cellspacing="0">
890 <table cellpadding="0" cellspacing="0" border="0">
892 <td class="md" nowrap valign="top">bool InspSocket::Poll </td>
893 <td class="md" valign="top">( </td>
894 <td class="mdname1" valign="top" nowrap> </td>
895 <td class="md" valign="top"> ) </td>
896 <td class="md" nowrap></td>
902 <table cellspacing="5" cellpadding="0" border="0">
910 Only the core should call this function.
912 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.
914 Definition at line <a class="el" href="socket_8cpp-source.html#l00216">216</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
916 References <a class="el" href="socketengine_8cpp-source.html#l00065">SocketEngine::AddFd()</a>, <a class="el" href="socket_8h-source.html#l00124">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#l00136">length</a>, <a class="el" href="socket_8cpp-source.html#l00263">OnConnected()</a>, <a class="el" href="socket_8cpp-source.html#l00267">OnDataReady()</a>, <a class="el" href="socket_8cpp-source.html#l00266">OnIncomingConnection()</a>, <a class="el" href="inspircd_8h-source.html#l00111">InspIRCd::SE</a>, <a class="el" href="socket_8cpp-source.html#l00247">SetState()</a>, and <a class="el" href="socketengine_8h-source.html#l00044">X_ESTAB_MODULE</a>.<div class="fragment"><pre class="fragment"><a name="l00217"></a>00217 {
917 <a name="l00218"></a>00218 <span class="keywordtype">int</span> incoming = -1;
918 <a name="l00219"></a>00219
919 <a name="l00220"></a>00220 <span class="keywordflow">switch</span> (this->state)
920 <a name="l00221"></a>00221 {
921 <a name="l00222"></a>00222 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTING">I_CONNECTING</a>:
922 <a name="l00223"></a>00223 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>);
923 <a name="l00224"></a>00224 <span class="comment">/* Our socket was in write-state, so delete it and re-add it</span>
924 <a name="l00225"></a>00225 <span class="comment"> * in read-state.</span>
925 <a name="l00226"></a>00226 <span class="comment"> */</span>
926 <a name="l00227"></a>00227 <a class="code" href="modules_8cpp.html#ServerInstance">ServerInstance</a>-><a class="code" href="classInspIRCd.html#SE">SE</a>-><a class="code" href="classSocketEngine.html#DelFd_28int_20fd_29">DelFd</a>(this->fd);
927 <a name="l00228"></a>00228 <a class="code" href="modules_8cpp.html#ServerInstance">ServerInstance</a>-><a class="code" href="classInspIRCd.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>);
928 <a name="l00229"></a>00229 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#OnConnected_28_29">OnConnected</a>();
929 <a name="l00230"></a>00230 <span class="keywordflow">break</span>;
930 <a name="l00231"></a>00231 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FLISTENING">I_LISTENING</a>:
931 <a name="l00232"></a>00232 <a class="code" href="classInspSocket.html#length">length</a> = <span class="keyword">sizeof</span> (<a class="code" href="classInspSocket.html#client">client</a>);
932 <a name="l00233"></a>00233 incoming = accept (this->fd, (sockaddr*)&<a class="code" href="classInspSocket.html#client">client</a>,&<a class="code" href="classInspSocket.html#length">length</a>);
933 <a name="l00234"></a>00234 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));
934 <a name="l00235"></a>00235 <span class="keywordflow">return</span> <span class="keyword">true</span>;
935 <a name="l00236"></a>00236 <span class="keywordflow">break</span>;
936 <a name="l00237"></a>00237 <span class="keywordflow">case</span> <a class="code" href="socket_8h.html#InspSocketStateI_5FCONNECTED">I_CONNECTED</a>:
937 <a name="l00238"></a>00238 <span class="keywordflow">return</span> this-><a class="code" href="classInspSocket.html#OnDataReady_28_29">OnDataReady</a>();
938 <a name="l00239"></a>00239 <span class="keywordflow">break</span>;
939 <a name="l00240"></a>00240 <span class="keywordflow">default</span>:
940 <a name="l00241"></a>00241 <span class="keywordflow">break</span>;
941 <a name="l00242"></a>00242 }
942 <a name="l00243"></a>00243
943 <a name="l00244"></a>00244 <span class="keywordflow">return</span> <span class="keyword">true</span>;
944 <a name="l00245"></a>00245 }
950 <a class="anchor" name="Read_28_29"></a><!-- doxytag: member="InspSocket::Read" ref="Read_28_29" args="()" --><p>
951 <table class="mdTable" cellpadding="2" cellspacing="0">
954 <table cellpadding="0" cellspacing="0" border="0">
956 <td class="md" nowrap valign="top">char * InspSocket::Read </td>
957 <td class="md" valign="top">( </td>
958 <td class="mdname1" valign="top" nowrap> </td>
959 <td class="md" valign="top"> ) </td>
960 <td class="md" nowrap><code> [virtual]</code></td>
966 <table cellspacing="5" cellpadding="0" border="0">
974 Reads all pending bytes from the socket into a char* array which can be up to 16 kilobytes in length.
978 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>.
980 References <a class="el" href="inspircd__io_8h-source.html#l00029">DEBUG</a>, <a class="el" href="socket_8h-source.html#l00106">ibuf</a>, and <a class="el" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log()</a>.<div class="fragment"><pre class="fragment"><a name="l00156"></a>00156 {
981 <a name="l00157"></a>00157 <span class="keywordtype">int</span> n = recv(this->fd,this->ibuf,<span class="keyword">sizeof</span>(this->ibuf),0);
982 <a name="l00158"></a>00158 <span class="keywordflow">if</span> (n > 0)
983 <a name="l00159"></a>00159 {
984 <a name="l00160"></a>00160 <a class="code" href="classInspSocket.html#ibuf_5B_36_35_35_33_35_5D">ibuf</a>[n] = 0;
985 <a name="l00161"></a>00161 <span class="keywordflow">return</span> <a class="code" href="classInspSocket.html#ibuf_5B_36_35_35_33_35_5D">ibuf</a>;
986 <a name="l00162"></a>00162 }
987 <a name="l00163"></a>00163 <span class="keywordflow">else</span>
988 <a name="l00164"></a>00164 {
989 <a name="l00165"></a>00165 <a class="code" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log</a>(<a class="code" href="inspircd__io_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"EOF or error on socket"</span>);
990 <a name="l00166"></a>00166 <span class="keywordflow">return</span> NULL;
991 <a name="l00167"></a>00167 }
992 <a name="l00168"></a>00168 }
998 <a class="anchor" name="SetState_28InspSocketState_20s_29"></a><!-- doxytag: member="InspSocket::SetState" ref="SetState_28InspSocketState_20s_29" args="(InspSocketState s)" --><p>
999 <table class="mdTable" cellpadding="2" cellspacing="0">
1002 <table cellpadding="0" cellspacing="0" border="0">
1004 <td class="md" nowrap valign="top">void InspSocket::SetState </td>
1005 <td class="md" valign="top">( </td>
1006 <td class="md" nowrap valign="top"><a class="el" href="socket_8h.html#InspSocketState">InspSocketState</a> </td>
1007 <td class="mdname1" valign="top" nowrap> <em>s</em> </td>
1008 <td class="md" valign="top"> ) </td>
1009 <td class="md" nowrap></td>
1015 <table cellspacing="5" cellpadding="0" border="0">
1023 Changes the socket's state.
1025 The core uses this to change socket states, and you should not call it directly.
1027 Definition at line <a class="el" href="socket_8cpp-source.html#l00247">247</a> of file <a class="el" href="socket_8cpp-source.html">socket.cpp</a>.
1029 References <a class="el" href="inspircd__io_8h-source.html#l00029">DEBUG</a>, <a class="el" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log()</a>, and <a class="el" href="socket_8h-source.html#l00072">state</a>.
1031 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>.<div class="fragment"><pre class="fragment"><a name="l00248"></a>00248 {
1032 <a name="l00249"></a>00249 <a class="code" href="globals_8h.html#log_28int_20level_2C_20char_20_2Atext_2C_2E_2E_2E_29">log</a>(<a class="code" href="inspircd__io_8h.html#DEBUG">DEBUG</a>,<span class="stringliteral">"Socket state change"</span>);
1033 <a name="l00250"></a>00250 this-><a class="code" href="classInspSocket.html#state">state</a> = s;
1034 <a name="l00251"></a>00251 }
1040 <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>
1041 <table class="mdTable" cellpadding="2" cellspacing="0">
1044 <table cellpadding="0" cellspacing="0" border="0">
1046 <td class="md" nowrap valign="top">bool InspSocket::Timeout </td>
1047 <td class="md" valign="top">( </td>
1048 <td class="md" nowrap valign="top">time_t </td>
1049 <td class="mdname1" valign="top" nowrap> <em>current</em> </td>
1050 <td class="md" valign="top"> ) </td>
1051 <td class="md" nowrap></td>
1057 <table cellspacing="5" cellpadding="0" border="0">
1065 This function checks if the socket has timed out yet, given the current time in the parameter.
1067 <dl compact><dt><b>Returns:</b></dt><dd>true if timed out, false if not timed out</dd></dl>
1070 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>.
1072 References <a class="el" href="socket_8cpp-source.html#l00181">FlushWriteBuffer()</a>, <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#l00264">OnError()</a>, <a class="el" href="socket_8cpp-source.html#l00268">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 {
1073 <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>))
1074 <a name="l00200"></a>00200 {
1075 <a name="l00201"></a>00201 <span class="comment">// for non-listening sockets, the timeout can occur</span>
1076 <a name="l00202"></a>00202 <span class="comment">// which causes termination of the connection after</span>
1077 <a name="l00203"></a>00203 <span class="comment">// the given number of seconds without a successful</span>
1078 <a name="l00204"></a>00204 <span class="comment">// connection.</span>
1079 <a name="l00205"></a>00205 this-><a class="code" href="classInspSocket.html#OnTimeout_28_29">OnTimeout</a>();
1080 <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>);
1081 <a name="l00207"></a>00207 <a class="code" href="classInspSocket.html#timeout">timeout</a> = <span class="keyword">true</span>;
1082 <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>;
1083 <a name="l00209"></a>00209 <span class="keywordflow">return</span> <span class="keyword">true</span>;
1084 <a name="l00210"></a>00210 }
1085 <a name="l00211"></a>00211 <span class="keywordflow">if</span> (this->Buffer.length())
1086 <a name="l00212"></a>00212 this-><a class="code" href="classInspSocket.html#FlushWriteBuffer_28_29">FlushWriteBuffer</a>();
1087 <a name="l00213"></a>00213 <span class="keywordflow">return</span> <span class="keyword">false</span>;
1088 <a name="l00214"></a>00214 }
1094 <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>
1095 <table class="mdTable" cellpadding="2" cellspacing="0">
1098 <table cellpadding="0" cellspacing="0" border="0">
1100 <td class="md" nowrap valign="top">int InspSocket::Write </td>
1101 <td class="md" valign="top">( </td>
1102 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> </td>
1103 <td class="mdname1" valign="top" nowrap> <em>data</em> </td>
1104 <td class="md" valign="top"> ) </td>
1105 <td class="md" nowrap><code> [virtual]</code></td>
1111 <table cellspacing="5" cellpadding="0" border="0">
1119 Writes a <a class="el" href="namespaceirc.html#string">std::string</a> to the socket.
1121 No carriage returns or linefeeds are appended to the string. <dl compact><dt><b>Parameters:</b></dt><dd>
1122 <table border="0" cellspacing="2" cellpadding="0">
1123 <tr><td valign="top"></td><td valign="top"><em>data</em> </td><td>The data to send</td></tr>
1128 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>.
1130 References <a class="el" href="socket_8h-source.html#l00111">Buffer</a>, and <a class="el" href="socket_8cpp-source.html#l00181">FlushWriteBuffer()</a>.<div class="fragment"><pre class="fragment"><a name="l00175"></a>00175 {
1131 <a name="l00176"></a>00176 this-><a class="code" href="classInspSocket.html#Buffer">Buffer</a> = this-><a class="code" href="classInspSocket.html#Buffer">Buffer</a> + data;
1132 <a name="l00177"></a>00177 this-><a class="code" href="classInspSocket.html#FlushWriteBuffer_28_29">FlushWriteBuffer</a>();
1133 <a name="l00178"></a>00178 <span class="keywordflow">return</span> data.length();
1134 <a name="l00179"></a>00179 }
1140 <hr><h2>Member Data Documentation</h2>
1141 <a class="anchor" name="addr"></a><!-- doxytag: member="InspSocket::addr" ref="addr" args="" --><p>
1142 <table class="mdTable" cellpadding="2" cellspacing="0">
1145 <table cellpadding="0" cellspacing="0" border="0">
1147 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#addr">InspSocket::addr</a><code> [private]</code> </td>
1153 <table cellspacing="5" cellpadding="0" border="0">
1161 The host being connected to, in sockaddr form.
1165 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>.
1167 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>. </td>
1170 <a class="anchor" name="addy"></a><!-- doxytag: member="InspSocket::addy" ref="addy" args="" --><p>
1171 <table class="mdTable" cellpadding="2" cellspacing="0">
1174 <table cellpadding="0" cellspacing="0" border="0">
1176 <td class="md" nowrap valign="top">in_addr <a class="el" href="classInspSocket.html#addy">InspSocket::addy</a><code> [private]</code> </td>
1182 <table cellspacing="5" cellpadding="0" border="0">
1190 The host being connected to, in in_addr form.
1194 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>.
1196 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>. </td>
1199 <a class="anchor" name="Buffer"></a><!-- doxytag: member="InspSocket::Buffer" ref="Buffer" args="" --><p>
1200 <table class="mdTable" cellpadding="2" cellspacing="0">
1203 <table cellpadding="0" cellspacing="0" border="0">
1205 <td class="md" nowrap valign="top"><a class="el" href="namespaceirc.html#string">std::string</a> <a class="el" href="classInspSocket.html#Buffer">InspSocket::Buffer</a><code> [private]</code> </td>
1211 <table cellspacing="5" cellpadding="0" border="0">
1219 The output buffer for this socket.
1223 Definition at line <a class="el" href="socket_8h-source.html#l00111">111</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1225 Referenced by <a class="el" href="socket_8cpp-source.html#l00181">FlushWriteBuffer()</a>, and <a class="el" href="socket_8cpp-source.html#l00174">Write()</a>. </td>
1228 <a class="anchor" name="client"></a><!-- doxytag: member="InspSocket::client" ref="client" args="" --><p>
1229 <table class="mdTable" cellpadding="2" cellspacing="0">
1232 <table cellpadding="0" cellspacing="0" border="0">
1234 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#client">InspSocket::client</a><code> [private]</code> </td>
1240 <table cellspacing="5" cellpadding="0" border="0">
1248 Client sockaddr structure used by accept().
1252 Definition at line <a class="el" href="socket_8h-source.html#l00124">124</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1254 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>. </td>
1257 <a class="anchor" name="fd"></a><!-- doxytag: member="InspSocket::fd" ref="fd" args="" --><p>
1258 <table class="mdTable" cellpadding="2" cellspacing="0">
1261 <table cellpadding="0" cellspacing="0" border="0">
1263 <td class="md" nowrap valign="top">int <a class="el" href="classInspSocket.html#fd">InspSocket::fd</a><code> [private]</code> </td>
1269 <table cellspacing="5" cellpadding="0" border="0">
1277 The file descriptor of this socket.
1281 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>.
1283 Referenced by <a class="el" href="socket_8cpp-source.html#l00138">Close()</a>, <a class="el" href="socket_8cpp-source.html#l00258">GetFd()</a>, and <a class="el" href="socket_8cpp-source.html#l00050">InspSocket()</a>. </td>
1286 <a class="anchor" name="host"></a><!-- doxytag: member="InspSocket::host" ref="host" args="" --><p>
1287 <table class="mdTable" cellpadding="2" cellspacing="0">
1290 <table cellpadding="0" cellspacing="0" border="0">
1292 <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>
1298 <table cellspacing="5" cellpadding="0" border="0">
1306 The hostname connected to.
1310 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>
1313 <a class="anchor" name="ibuf_5B_36_35_35_33_35_5D"></a><!-- doxytag: member="InspSocket::ibuf" ref="ibuf_5B_36_35_35_33_35_5D" args="[65535]" --><p>
1314 <table class="mdTable" cellpadding="2" cellspacing="0">
1317 <table cellpadding="0" cellspacing="0" border="0">
1319 <td class="md" nowrap valign="top">char <a class="el" href="classInspSocket.html#ibuf_5B_36_35_35_33_35_5D">InspSocket::ibuf</a>[65535]<code> [private]</code> </td>
1325 <table cellspacing="5" cellpadding="0" border="0">
1333 Socket input buffer, used by read().
1335 The class which extends InspSocket is expected to implement an extendable buffer which can grow much larger than 64k, this buffer is just designed to be temporary storage. space.
1337 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>.
1339 Referenced by <a class="el" href="socket_8cpp-source.html#l00155">Read()</a>. </td>
1342 <a class="anchor" name="IP"></a><!-- doxytag: member="InspSocket::IP" ref="IP" args="" --><p>
1343 <table class="mdTable" cellpadding="2" cellspacing="0">
1346 <table cellpadding="0" cellspacing="0" border="0">
1348 <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>
1354 <table cellspacing="5" cellpadding="0" border="0">
1362 The IP address being connected to stored in string form for easy retrieval by accessors.
1366 Definition at line <a class="el" href="socket_8h-source.html#l00118">118</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1368 Referenced by <a class="el" href="socket_8cpp-source.html#l00150">GetIP()</a>, and <a class="el" href="socket_8cpp-source.html#l00050">InspSocket()</a>. </td>
1371 <a class="anchor" name="length"></a><!-- doxytag: member="InspSocket::length" ref="length" args="" --><p>
1372 <table class="mdTable" cellpadding="2" cellspacing="0">
1375 <table cellpadding="0" cellspacing="0" border="0">
1377 <td class="md" nowrap valign="top">socklen_t <a class="el" href="classInspSocket.html#length">InspSocket::length</a><code> [private]</code> </td>
1383 <table cellspacing="5" cellpadding="0" border="0">
1391 Used by accept() to indicate the sizes of the sockaddr_in structures.
1395 Definition at line <a class="el" href="socket_8h-source.html#l00136">136</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>.
1397 Referenced by <a class="el" href="socket_8cpp-source.html#l00216">Poll()</a>. </td>
1400 <a class="anchor" name="port"></a><!-- doxytag: member="InspSocket::port" ref="port" args="" --><p>
1401 <table class="mdTable" cellpadding="2" cellspacing="0">
1404 <table cellpadding="0" cellspacing="0" border="0">
1406 <td class="md" nowrap valign="top">int <a class="el" href="classInspSocket.html#port">InspSocket::port</a><code> [private]</code> </td>
1412 <table cellspacing="5" cellpadding="0" border="0">
1420 The port connected to, or the port this socket is listening on.
1424 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>
1427 <a class="anchor" name="server"></a><!-- doxytag: member="InspSocket::server" ref="server" args="" --><p>
1428 <table class="mdTable" cellpadding="2" cellspacing="0">
1431 <table cellpadding="0" cellspacing="0" border="0">
1433 <td class="md" nowrap valign="top">sockaddr_in <a class="el" href="classInspSocket.html#server">InspSocket::server</a><code> [private]</code> </td>
1439 <table cellspacing="5" cellpadding="0" border="0">
1447 <a class="el" href="classServer.html">Server</a> sockaddr structure used by accept().
1451 Definition at line <a class="el" href="socket_8h-source.html#l00130">130</a> of file <a class="el" href="socket_8h-source.html">socket.h</a>. </td>
1454 <a class="anchor" name="state"></a><!-- doxytag: member="InspSocket::state" ref="state" args="" --><p>
1455 <table class="mdTable" cellpadding="2" cellspacing="0">
1458 <table cellpadding="0" cellspacing="0" border="0">
1460 <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>
1466 <table cellspacing="5" cellpadding="0" border="0">
1474 The state for this socket, either listening, connecting, connected or error.
1478 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>.
1480 Referenced by <a class="el" href="socket_8cpp-source.html#l00253">GetState()</a>, <a class="el" href="socket_8cpp-source.html#l00045">InspSocket()</a>, <a class="el" href="socket_8cpp-source.html#l00247">SetState()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1483 <a class="anchor" name="timeout"></a><!-- doxytag: member="InspSocket::timeout" ref="timeout" args="" --><p>
1484 <table class="mdTable" cellpadding="2" cellspacing="0">
1487 <table cellpadding="0" cellspacing="0" border="0">
1489 <td class="md" nowrap valign="top">bool <a class="el" href="classInspSocket.html#timeout">InspSocket::timeout</a><code> [private]</code> </td>
1495 <table cellspacing="5" cellpadding="0" border="0">
1503 This value is true if the socket has timed out.
1507 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>.
1509 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1512 <a class="anchor" name="timeout_5Fend"></a><!-- doxytag: member="InspSocket::timeout_end" ref="timeout_5Fend" args="" --><p>
1513 <table class="mdTable" cellpadding="2" cellspacing="0">
1516 <table cellpadding="0" cellspacing="0" border="0">
1518 <td class="md" nowrap valign="top">time_t <a class="el" href="classInspSocket.html#timeout_5Fend">InspSocket::timeout_end</a><code> [private]</code> </td>
1524 <table cellspacing="5" cellpadding="0" border="0">
1532 When this time is reached, the socket times out if it is in the CONNECTING state.
1536 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>.
1538 Referenced by <a class="el" href="socket_8cpp-source.html#l00059">InspSocket()</a>, and <a class="el" href="socket_8cpp-source.html#l00197">Timeout()</a>. </td>
1541 <hr>The documentation for this class was generated from the following files:<ul>
1542 <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>
1543 <hr size="1"><address style="align: right;"><small>Generated on Mon Dec 19 18:05:22 2005 for InspIRCd by
1544 <a href="http://www.doxygen.org/index.html">
1545 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4-20050815 </small></address>