aboutsummaryrefslogtreecommitdiff
path: root/src/connectionmanager.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-11-02 11:29:19 +0000
committerMike Buland <eichlan@xagasoft.com>2006-11-02 11:29:19 +0000
commit80153a5bb5d3b41101e6bd6755b61fd0e57fadbc (patch)
tree6a2989723396348d509b63466bf53023f4f82739 /src/connectionmanager.cpp
parent54ef2750aef0c64df56daff50af7719f85017c33 (diff)
downloadlibbu++-80153a5bb5d3b41101e6bd6755b61fd0e57fadbc.tar.gz
libbu++-80153a5bb5d3b41101e6bd6755b61fd0e57fadbc.tar.bz2
libbu++-80153a5bb5d3b41101e6bd6755b61fd0e57fadbc.tar.xz
libbu++-80153a5bb5d3b41101e6bd6755b61fd0e57fadbc.zip
Added the new features that you need to make the connection manager, protocols,
and the connection monitor work in two-way-mode. Effectively you should be able to write systems that both serve and initiate connections, and only write one protocol.
Diffstat (limited to 'src/connectionmanager.cpp')
-rw-r--r--src/connectionmanager.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/connectionmanager.cpp b/src/connectionmanager.cpp
index 3e9f1a8..367b9d7 100644
--- a/src/connectionmanager.cpp
+++ b/src/connectionmanager.cpp
@@ -195,6 +195,7 @@ bool ConnectionManager::scanConnections( int nTimeout, bool bForceTimeout )
195 lActive.erase( l ); 195 lActive.erase( l );
196 continue; 196 continue;
197 } 197 }
198 (*i)->poll();
198 if( (*i)->hasOutput() ) 199 if( (*i)->hasOutput() )
199 { 200 {
200 (*i)->writeOutput(); 201 (*i)->writeOutput();
@@ -324,6 +325,23 @@ bool ConnectionManager::addConnection( int nSocket )
324 return true; 325 return true;
325} 326}
326 327
328void ConnectionManager::connect(
329 const char *lpAddress,
330 int nPort,
331 int nProtocolPort
332 )
333{
334 Connection *pCon = getInactiveConnection();
335 pCon->open( lpAddress, nPort );
336 int nSocket = pCon->getSocket();
337 FD_SET( nSocket, &fdActive );
338
339 pMonitor->onNewClientConnection( pCon, nProtocolPort );
340 pCon->getProtocol()->onNewClientConnection();
341
342 lActive.insert( lActive.end(), pCon );
343}
344
327Connection *ConnectionManager::getInactiveConnection() 345Connection *ConnectionManager::getInactiveConnection()
328{ 346{
329 if( lInactive.empty() ) 347 if( lInactive.empty() )