diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-11-26 17:29:22 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-11-26 17:29:22 +0000 |
commit | f3a1d7ea4bc13126996daf10031e89fd850c5945 (patch) | |
tree | 7b722843906ded7ce5d93338f0cdb45ce059f732 /src/modules/m_spanningtree.cpp | |
parent | 17b5f19bf1476cb22ccb409145600dac7209f823 (diff) |
Added listening socket support for InspSocket
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1957 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree.cpp')
-rw-r--r-- | src/modules/m_spanningtree.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 95d4d4398..4cc4b50d6 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -39,6 +39,12 @@ class TreeSocket : public InspSocket Srv->Log(DEBUG,"Create new"); myhost = host; } + + TreeSocket(int newfd) + : InspSocket(newfd) + { + // Associate with an existing file descriptor (accepted from incoming connection) + } virtual bool OnConnected() { @@ -88,9 +94,17 @@ class TreeSocket : public InspSocket Srv->SendToModeMask("o",WM_AND,"*** CLOSED ***"); } - virtual int OnIncomingConnection() + virtual int OnIncomingConnection(int newsock, char* ip) { Srv->SendToModeMask("o",WM_AND,"*** INCOMING ***"); + // use the (int) constructor to associate an incoming + // connection with a class, without actually creating + // a connection or binding from scratch. + TreeSocket* s = new TreeSocket(newsock); + Srv->AddSocket(s); + char message[1024]; + sprintf(message,"Added new socket to list with fd %d from %s",newsock,ip); + Srv->Log(DEBUG,message); return true; } }; @@ -113,6 +127,8 @@ class ModuleSpanningTree : public Module Srv = new Server; Srv->AddCommand("CONNECTTEST",handle_connecttest,'o',1,"m_spanningtree.so"); Srv->Log(DEBUG,"ModCreate"); + TreeSocket* listeningsock = new TreeSocket("127.0.0.1",11111,true,10); + Srv->AddSocket(listeningsock); } virtual void OnUserJoin(userrec* user, chanrec* channel) |