hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp
branchRCL_3
changeset 4 73ff0d268e1d
parent 0 a03f92240627
--- a/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp	Tue Feb 02 10:12:29 2010 +0200
+++ b/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp	Sat Feb 20 00:22:34 2010 +0200
@@ -19,9 +19,9 @@
 
 // INCLUDE FILES
 #include "CIPProxyEngine.h"
-#include "CTCPPortListener.h"
+#include "Ctcpportlistener.h"
 #include "CLocalTCPConnection.h"
-#include "CSocketRouter.h"
+#include "Csocketrouter.h"
 #include "MIPProxyEngineObserver.h"
 #include "MHostConnection.h"
 #include "MAbstractConnection.h"
@@ -528,6 +528,7 @@
     DEBUG_PRINT( DEBUG_STRING(
         "CIPProxyEngine::CloseTCPConnection(), port=%d"), aPort );
 
+    // Delete local TCP connections
     TInt index = FindLocalTCPConn( aPort );
     if ( index > -1 )
         {
@@ -538,6 +539,25 @@
         DEBUG_PRINT( DEBUG_STRING(
             "CIPProxyEngine::CloseTCPConnection(), conn deleted.") );
         }
+    
+    // stop listening on this port
+    TInt peerListenerArrayCount = iPeerListenerArray->Count();
+    for ( TInt i = 0; i < peerListenerArrayCount; i++ )
+        {
+        CTCPPortListener* listener = iPeerListenerArray->At( i );
+        if(listener->Port() == aPort)
+            {
+            listener->Cancel();
+            iPeerListenerArray->Delete(i);
+            delete listener;
+            break;
+            }
+        }
+    
+    if(iPeerListenerArray->Count() == 0)
+        {
+        iListening = EFalse;
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -552,6 +572,8 @@
     iSocketRouter->ResetQueue();
     iSocketRouter->RemoveAllPeers();
 
+    iLocalConnArray->ResetAndDestroy();
+    
     StopListening();
 
     if ( iPeerListenerArray )