From 097b2479d0393d8a8bada4a50708d7a2404045ca Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 12 Dec 2005 13:32:15 +0000 Subject: Added new docs for class SocketEngine git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2339 e03df62e-2008-0410-955e-edbf42e46eb7 --- docs/module-doc/classInspSocket.html | 477 +++++++++++++++++++---------------- 1 file changed, 258 insertions(+), 219 deletions(-) (limited to 'docs/module-doc/classInspSocket.html') diff --git a/docs/module-doc/classInspSocket.html b/docs/module-doc/classInspSocket.html index 6aee4b7e0..b4c7e7fba 100644 --- a/docs/module-doc/classInspSocket.html +++ b/docs/module-doc/classInspSocket.html @@ -43,6 +43,8 @@ Collaboration diagram for InspSocket:

bool Poll () +int GetFd () + virtual void Close () virtual ~InspSocket () @@ -109,11 +111,11 @@ Definition at line 30 of f

-Definition at line 46 of file socket.cpp. +Definition at line 49 of file socket.cpp.

-References I_DISCONNECTED, and state.

00047 {
-00048         this->state = I_DISCONNECTED;
-00049 }
+References I_DISCONNECTED, and state.
00050 {
+00051         this->state = I_DISCONNECTED;
+00052 }
 

@@ -155,13 +157,14 @@ References I

-Definition at line 51 of file socket.cpp. +Definition at line 54 of file socket.cpp.

-References fd, I_CONNECTED, IP, and state.

00052 {
-00053         this->fd = newfd;
-00054         this->state = I_CONNECTED;
-00055         this->IP = ip;
-00056 }
+References SocketEngine::AddFd(), fd, I_CONNECTED, IP, state, and X_ESTAB_MODULE.
00055 {
+00056         this->fd = newfd;
+00057         this->state = I_CONNECTED;
+00058         this->IP = ip;
+00059         SE->AddFd(this->fd,true,X_ESTAB_MODULE);
+00060 }
 

@@ -215,81 +218,83 @@ References fd, 58 of file socket.cpp. -

-References addr, addy, Close(), DEBUG, fd, I_CONNECTING, I_ERR_BIND, I_ERR_CONNECT, I_ERR_SOCKET, I_ERROR, I_LISTENING, IP, OnError(), state, timeout, and timeout_end.

00059 {
-00060         if (listening) {
-00061                 if ((this->fd = OpenTCPSocket()) == ERROR)
-00062                 {
-00063                         this->fd = -1;
-00064                         this->state = I_ERROR;
-00065                         this->OnError(I_ERR_SOCKET);
-00066                         log(DEBUG,"OpenTCPSocket() error");
-00067                         return;
-00068                 }
-00069                 else
-00070                 {
-00071                         if (BindSocket(this->fd,this->client,this->server,port,(char*)host.c_str()) == ERROR)
-00072                         {
-00073                                 this->Close();
-00074                                 this->fd = -1;
-00075                                 this->state = I_ERROR;
-00076                                 this->OnError(I_ERR_BIND);
-00077                                 log(DEBUG,"BindSocket() error %s",strerror(errno));
-00078                                 return;
-00079                         }
-00080                         else
-00081                         {
-00082                                 this->state = I_LISTENING;
-00083                                 log(DEBUG,"New socket now in I_LISTENING state");
-00084                                 return;
-00085                         }
-00086                 }                       
-00087         } else {
-00088                 char* ip;
-00089                 this->host = host;
-00090                 hostent* hoste = gethostbyname(host.c_str());
-00091                 if (!hoste) {
-00092                         ip = (char*)host.c_str();
-00093                 } else {
-00094                         struct in_addr* ia = (in_addr*)hoste->h_addr;
-00095                         ip = inet_ntoa(*ia);
-00096                 }
-00097 
-00098                 this->IP = ip;
-00099 
-00100                 timeout_end = time(NULL)+maxtime;
-00101                 timeout = false;
-00102                 if ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
-00103                 {
-00104                         this->state = I_ERROR;
-00105                         this->OnError(I_ERR_SOCKET);
-00106                         return;
-00107                 }
-00108                 this->port = port;
-00109                 inet_aton(ip,&addy);
-00110                 addr.sin_family = AF_INET;
-00111                 addr.sin_addr = addy;
-00112                 addr.sin_port = htons(this->port);
-00113 
-00114                 int flags;
-00115                 flags = fcntl(this->fd, F_GETFL, 0);
-00116                 fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
-00117 
-00118                 if(connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
-00119                 {
-00120                         if (errno != EINPROGRESS)
-00121                         {
-00122                                 this->Close();
-00123                                 this->OnError(I_ERR_CONNECT);
-00124                                 this->state = I_ERROR;
-00125                                 return;
-00126                         }
-00127                 }
-00128                 this->state = I_CONNECTING;
-00129                 return;
-00130         }
-00131 }
+Definition at line 62 of file socket.cpp.
+

+References SocketEngine::AddFd(), addr, addy, Close(), DEBUG, fd, I_CONNECTING, I_ERR_BIND, I_ERR_CONNECT, I_ERR_SOCKET, I_ERROR, I_LISTENING, IP, OnError(), state, timeout, timeout_end, and X_ESTAB_MODULE.

00063 {
+00064         if (listening) {
+00065                 if ((this->fd = OpenTCPSocket()) == ERROR)
+00066                 {
+00067                         this->fd = -1;
+00068                         this->state = I_ERROR;
+00069                         this->OnError(I_ERR_SOCKET);
+00070                         log(DEBUG,"OpenTCPSocket() error");
+00071                         return;
+00072                 }
+00073                 else
+00074                 {
+00075                         if (BindSocket(this->fd,this->client,this->server,port,(char*)host.c_str()) == ERROR)
+00076                         {
+00077                                 this->Close();
+00078                                 this->fd = -1;
+00079                                 this->state = I_ERROR;
+00080                                 this->OnError(I_ERR_BIND);
+00081                                 log(DEBUG,"BindSocket() error %s",strerror(errno));
+00082                                 return;
+00083                         }
+00084                         else
+00085                         {
+00086                                 this->state = I_LISTENING;
+00087                                 SE->AddFd(this->fd,true,X_ESTAB_MODULE);
+00088                                 log(DEBUG,"New socket now in I_LISTENING state");
+00089                                 return;
+00090                         }
+00091                 }                       
+00092         } else {
+00093                 char* ip;
+00094                 this->host = host;
+00095                 hostent* hoste = gethostbyname(host.c_str());
+00096                 if (!hoste) {
+00097                         ip = (char*)host.c_str();
+00098                 } else {
+00099                         struct in_addr* ia = (in_addr*)hoste->h_addr;
+00100                         ip = inet_ntoa(*ia);
+00101                 }
+00102 
+00103                 this->IP = ip;
+00104 
+00105                 timeout_end = time(NULL)+maxtime;
+00106                 timeout = false;
+00107                 if ((this->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+00108                 {
+00109                         this->state = I_ERROR;
+00110                         this->OnError(I_ERR_SOCKET);
+00111                         return;
+00112                 }
+00113                 this->port = port;
+00114                 inet_aton(ip,&addy);
+00115                 addr.sin_family = AF_INET;
+00116                 addr.sin_addr = addy;
+00117                 addr.sin_port = htons(this->port);
+00118 
+00119                 int flags;
+00120                 flags = fcntl(this->fd, F_GETFL, 0);
+00121                 fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
+00122 
+00123                 if(connect(this->fd, (sockaddr*)&this->addr,sizeof(this->addr)) == -1)
+00124                 {
+00125                         if (errno != EINPROGRESS)
+00126                         {
+00127                                 this->Close();
+00128                                 this->OnError(I_ERR_CONNECT);
+00129                                 this->state = I_ERROR;
+00130                                 return;
+00131                         }
+00132                 }
+00133                 this->state = I_CONNECTING;
+00134                 SE->AddFd(this->fd,false,X_ESTAB_MODULE);
+00135                 return;
+00136         }
+00137 }
 

@@ -321,11 +326,11 @@ References addr,

-Definition at line 254 of file socket.cpp. +Definition at line 265 of file socket.cpp.

-References Close().

00255 {
-00256         this->Close();
-00257 }
+References Close().
00266 {
+00267         this->Close();
+00268 }
 

@@ -358,19 +363,55 @@ References Close().

-Definition at line 133 of file socket.cpp. +Definition at line 139 of file socket.cpp. +

+References fd, and OnClose(). +

+Referenced by InspSocket(), and ~InspSocket().

00140 {
+00141         if (this->fd != -1)
+00142         {
+00143                 this->OnClose();
+00144                 shutdown(this->fd,2);
+00145                 close(this->fd);
+00146                 this->fd = -1;
+00147         }
+00148 }
+
+

+ + + +

+ + + + +
+ + + + + + + + +
int InspSocket::GetFd  ) 
+
+ + + + @@ -402,11 +443,11 @@ Referenced by InspSocket()

-Definition at line 144 of file socket.cpp. +Definition at line 150 of file socket.cpp.

-References IP.

00145 {
-00146         return this->IP;
-00147 }
+References IP.
00151 {
+00152         return this->IP;
+00153 }
 

@@ -438,11 +479,11 @@ References IP.

241 of file socket.cpp. +Definition at line 247 of file socket.cpp.

-References state.

00242 {
-00243         return this->state;
-00244 }
+References state.
00248 {
+00249         return this->state;
+00250 }
 

@@ -474,9 +515,9 @@ References state.

-Definition at line 252 of file socket.cpp. +Definition at line 263 of file socket.cpp.

-Referenced by Close().

00252 { return; }
+Referenced by Close().
00263 { return; }
 

@@ -508,9 +549,9 @@ Referenced by Close().

-Definition at line 246 of file socket.cpp. +Definition at line 257 of file socket.cpp.

-Referenced by Poll().

00246 { return true; }
+Referenced by Poll().
00257 { return true; }
 

@@ -542,9 +583,9 @@ Referenced by Poll().

-Definition at line 250 of file socket.cpp. +Definition at line 261 of file socket.cpp.

-Referenced by Poll().

00250 { return true; }
+Referenced by Poll().
00261 { return true; }
 

@@ -576,7 +617,7 @@ Referenced by Poll().

-Definition at line 248 of file socket.cpp.

00248 { return 0; }
+Definition at line 259 of file socket.cpp.
00259 { return 0; }
 

@@ -609,9 +650,9 @@ Definition at line 248 o

-Definition at line 247 of file socket.cpp. +Definition at line 258 of file socket.cpp.

-Referenced by InspSocket(), and Poll().

00247 { return; }
+Referenced by InspSocket(), and Poll().
00258 { return; }
 

@@ -653,9 +694,9 @@ Referenced by InspSocket()

-Definition at line 249 of file socket.cpp. +Definition at line 260 of file socket.cpp.

-Referenced by Poll().

00249 { return 0; }
+Referenced by Poll().
00260 { return 0; }
 

@@ -687,9 +728,9 @@ Referenced by Poll().

-Definition at line 251 of file socket.cpp. +Definition at line 262 of file socket.cpp.

-Referenced by Poll().

00251 { return; }
+Referenced by Poll().
00262 { return; }
 

@@ -721,50 +762,50 @@ Referenced by Poll().

-Definition at line 191 of file socket.cpp. -

-References client, fd, I_CONNECTED, I_CONNECTING, I_ERR_TIMEOUT, I_ERROR, I_LISTENING, length, OnConnected(), OnDataReady(), OnError(), OnIncomingConnection(), OnTimeout(), polls, SetState(), state, timeout, and timeout_end.

00192 {
-00193         if ((time(NULL) > timeout_end) && (this->state == I_CONNECTING))
-00194         {
-00195                 // for non-listening sockets, the timeout can occur
-00196                 // which causes termination of the connection after
-00197                 // the given number of seconds without a successful
-00198                 // connection.
-00199                 this->OnTimeout();
-00200                 this->OnError(I_ERR_TIMEOUT);
-00201                 timeout = true;
-00202                 this->state = I_ERROR;
-00203                 return false;
-00204         }
-00205         polls.fd = this->fd;
-00206         state == I_CONNECTING ? polls.events = POLLOUT : polls.events = POLLIN;
-00207         int ret = poll(&polls,1,1);
-00208 
-00209         if (ret > 0)
-00210         {
-00211                 int incoming = -1;
-00212                 
-00213                 switch (this->state)
-00214                 {
-00215                         case I_CONNECTING:
-00216                                 this->SetState(I_CONNECTED);
-00217                                 return this->OnConnected();
-00218                         break;
-00219                         case I_LISTENING:
-00220                                 length = sizeof (client);
-00221                                 incoming = accept (this->fd, (sockaddr*)&client,&length);
-00222                                 this->OnIncomingConnection(incoming,inet_ntoa(client.sin_addr));
-00223                                 return true;
-00224                         break;
-00225                         case I_CONNECTED:
-00226                                 return this->OnDataReady();
-00227                         break;
-00228                         default:
-00229                         break;
-00230                 }
-00231         }
-00232         return true;
-00233 }
+Definition at line 197 of file socket.cpp.
+

+References SocketEngine::AddFd(), client, SocketEngine::DelFd(), I_CONNECTED, I_CONNECTING, I_ERR_TIMEOUT, I_ERROR, I_LISTENING, length, OnConnected(), OnDataReady(), OnError(), OnIncomingConnection(), OnTimeout(), SetState(), state, timeout, timeout_end, and X_ESTAB_MODULE.

00198 {
+00199         if ((time(NULL) > timeout_end) && (this->state == I_CONNECTING))
+00200         {
+00201                 // for non-listening sockets, the timeout can occur
+00202                 // which causes termination of the connection after
+00203                 // the given number of seconds without a successful
+00204                 // connection.
+00205                 this->OnTimeout();
+00206                 this->OnError(I_ERR_TIMEOUT);
+00207                 timeout = true;
+00208                 this->state = I_ERROR;
+00209                 return false;
+00210         }
+00211 
+00212         int incoming = -1;
+00213         
+00214         switch (this->state)
+00215         {
+00216                 case I_CONNECTING:
+00217                         this->SetState(I_CONNECTED);
+00218                         /* Our socket was in write-state, so delete it and re-add it
+00219                          * in read-state.
+00220                          */
+00221                         SE->DelFd(this->fd);
+00222                         SE->AddFd(this->fd,true,X_ESTAB_MODULE);
+00223                         return this->OnConnected();
+00224                 break;
+00225                 case I_LISTENING:
+00226                         length = sizeof (client);
+00227                         incoming = accept (this->fd, (sockaddr*)&client,&length);
+00228                         this->OnIncomingConnection(incoming,inet_ntoa(client.sin_addr));
+00229                         return true;
+00230                 break;
+00231                 case I_CONNECTED:
+00232                         return this->OnDataReady();
+00233                 break;
+00234                 default:
+00235                 break;
+00236         }
+00237 
+00238         return true;
+00239 }
 

@@ -796,21 +837,21 @@ References client,

-Definition at line 149 of file socket.cpp. +Definition at line 155 of file socket.cpp.

-References DEBUG, and ibuf.

00150 {
-00151         int n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0);
-00152         if (n > 0)
-00153         {
-00154                 ibuf[n] = 0;
-00155                 return ibuf;
-00156         }
-00157         else
-00158         {
-00159                 log(DEBUG,"EOF or error on socket");
-00160                 return NULL;
-00161         }
-00162 }
+References DEBUG, and ibuf.
00156 {
+00157         int n = recv(this->fd,this->ibuf,sizeof(this->ibuf),0);
+00158         if (n > 0)
+00159         {
+00160                 ibuf[n] = 0;
+00161                 return ibuf;
+00162         }
+00163         else
+00164         {
+00165                 log(DEBUG,"EOF or error on socket");
+00166                 return NULL;
+00167         }
+00168 }
 

@@ -843,14 +884,14 @@ References DEBUG, and

-Definition at line 235 of file socket.cpp. +Definition at line 241 of file socket.cpp.

References DEBUG, and state.

-Referenced by Poll().

00236 {
-00237         log(DEBUG,"Socket state change");
-00238         this->state = s;
-00239 }
+Referenced by Poll().
00242 {
+00243         log(DEBUG,"Socket state change");
+00244         this->state = s;
+00245 }
 

@@ -883,27 +924,27 @@ Referenced by Poll().

-Definition at line 168 of file socket.cpp.

00169 {
-00170         char* d = (char*)data.c_str();
-00171         unsigned int written = 0;
-00172         int n = 0;
-00173         int s = data.length();
-00174         while ((written < data.length()) && (n >= 0))
-00175         {
-00176                 n = send(this->fd,d,s,0);
-00177                 if (n > 0)
-00178                 {
-00179                         // If we didnt write everything, advance
-00180                         // the pointers so that when we retry
-00181                         // the next time around the loop, we try
-00182                         // to write what we failed to write before.
-00183                         written += n;
-00184                         s -= n;
-00185                         d += n;
-00186                 }
-00187         }
-00188         return written;
-00189 }
+Definition at line 174 of file socket.cpp.
00175 {
+00176         char* d = (char*)data.c_str();
+00177         unsigned int written = 0;
+00178         int n = 0;
+00179         int s = data.length();
+00180         while ((written < data.length()) && (n >= 0))
+00181         {
+00182                 n = send(this->fd,d,s,0);
+00183                 if (n > 0)
+00184                 {
+00185                         // If we didnt write everything, advance
+00186                         // the pointers so that when we retry
+00187                         // the next time around the loop, we try
+00188                         // to write what we failed to write before.
+00189                         written += n;
+00190                         s -= n;
+00191                         d += n;
+00192                 }
+00193         }
+00194         return written;
+00195 }
 

@@ -934,7 +975,7 @@ Definition at line 168 o

Definition at line 37 of file socket.h.

-Referenced by InspSocket(). +Referenced by InspSocket().

+   + + +

+

-References fd, and OnClose(). +Definition at line 252 of file socket.cpp.

-Referenced by InspSocket(), and ~InspSocket().

00134 {
-00135         if (this->fd != -1)
-00136         {
-00137                 this->OnClose();
-00138                 shutdown(this->fd,2);
-00139                 close(this->fd);
-00140                 this->fd = -1;
-00141         }
-00142 }
+References fd.
00253 {
+00254         return this->fd;
+00255 }
 

@@ -961,7 +1002,7 @@ Referenced by InspSocket() Definition at line 38 of file socket.h.

-Referenced by InspSocket(). +Referenced by InspSocket().

@@ -988,7 +1029,7 @@ Referenced by InspSocket() Definition at line 44 of file socket.h.

-Referenced by Poll(). +Referenced by Poll().

@@ -1015,7 +1056,7 @@ Referenced by Poll().

Definition at line 33 of file socket.h.

-Referenced by Close(), InspSocket(), and Poll(). +Referenced by Close(), GetFd(), and InspSocket().

@@ -1067,7 +1108,7 @@ Definition at line 34 of f

Definition at line 42 of file socket.h.

-Referenced by Read(). +Referenced by Read().

@@ -1094,7 +1135,7 @@ Referenced by Read().

Definition at line 43 of file socket.h.

-Referenced by GetIP(), and InspSocket(). +Referenced by GetIP(), and InspSocket().

@@ -1121,7 +1162,7 @@ Referenced by GetIP(), a

Definition at line 46 of file socket.h.

-Referenced by Poll(). +Referenced by Poll().

@@ -1146,9 +1187,7 @@ Referenced by Poll().

-Definition at line 41 of file socket.h. -

-Referenced by Poll(). +Definition at line 41 of file socket.h.

@@ -1225,7 +1264,7 @@ Definition at line 45 of f

Definition at line 36 of file socket.h.

-Referenced by GetState(), InspSocket(), Poll(), and SetState(). +Referenced by GetState(), InspSocket(), Poll(), and SetState().

@@ -1252,7 +1291,7 @@ Referenced by GetState()

Definition at line 40 of file socket.h.

-Referenced by InspSocket(), and Poll(). +Referenced by InspSocket(), and Poll().

@@ -1279,12 +1318,12 @@ Referenced by InspSocket() Definition at line 39 of file socket.h.

-Referenced by InspSocket(), and Poll(). +Referenced by InspSocket(), and Poll().


The documentation for this class was generated from the following files: -
Generated on Fri Dec 9 20:20:12 2005 for InspIRCd by  +
Generated on Mon Dec 12 13:31:12 2005 for InspIRCd by  doxygen 1.4.4-20050815
-- cgit v1.3.1-10-gc9f91