hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp
changeset 13 33016869e0dd
parent 0 a03f92240627
--- a/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp	Tue Feb 02 01:57:15 2010 +0200
+++ b/hti/HtiServicePlugins/HtiIpProxyServicePlugin/IPProxyEngine/Src/CIPProxyEngine.cpp	Fri Apr 16 16:37:27 2010 +0300
@@ -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 )