]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socket.h
Use IS_OPER(u) instead of checking for umode +o to correctly add opers during bursts...
[user/henk/code/inspircd.git] / include / socket.h
index a26c1256d2db4f2967aa209dc442ed4827acf3cf..2fcb149b19f8ff208355221cb3066d4def4563f7 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -135,15 +135,17 @@ namespace irc
                 * or a negative value upon failure (negative values are invalid file
                 * descriptors)
                 */
-               CoreExport int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM);
+               CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM);
        }
 }
 
+
+
 /** This class handles incoming connections on client ports.
  * It will create a new User for every valid connection
  * and assign it a file descriptor.
  */
-class CoreExport ListenSocket : public EventHandler
+class CoreExport ListenSocketBase : public EventHandler
 {
  protected:
        /** The creator/owner of this object
@@ -169,13 +171,13 @@ class CoreExport ListenSocket : public EventHandler
  public:
        /** Create a new listening socket
         */
-       ListenSocket(InspIRCd* Instance, int port, char* addr);
+       ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr);
        /** Handle an I/O event
         */
        void HandleEvent(EventType et, int errornum = 0);
        /** Close the socket
         */
-       ~ListenSocket();
+       ~ListenSocketBase();
        /** Set descriptive text
         */
        void SetDescription(const std::string &description)
@@ -200,6 +202,24 @@ class CoreExport ListenSocket : public EventHandler
        {
                return bind_addr;
        }
+
+       /** Handles sockets internals crap of a connection, convenience wrapper really
+        */
+       void AcceptInternal();
+
+       /** Called when a new connection has successfully been accepted on this listener.
+        * @param ipconnectedto The IP address the connection arrived on
+        * @param fd The file descriptor of the new connection
+        * @param incomingip The IP from which the connection was made
+        */
+       virtual void OnAcceptReady(const std::string &ipconnectedto, int fd, const std::string &incomingip) = 0;
+};
+
+class CoreExport ClientListenSocket : public ListenSocketBase
+{
+       virtual void OnAcceptReady(const std::string &ipconnectedto, int fd, const std::string &incomingip);
+ public:
+       ClientListenSocket(InspIRCd* Instance, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr) { }
 };
 
 #endif