Hello,
I have a class that inherits from the TcpListener, this class Shadows the Start method just to call the base Start() and the base BeginAcceptTcpClient(). From time to time the method is called but the port is not opened (netstat does not show the port open).
The class looks like this
Public Class ExtendedTcpListener
Inherits System.Net.Sockets.TcpListener
Public Shadows Sub Start()
SyncLock (m_stopLock)
MyBase.Start()
MyBase.BeginAcceptTcpClient(AddressOf Me.CompleteAcceptTcpClient, Me)
My.Application.Log.WriteEntry("Extended Tcp Listener started ...", TraceEventType.Verbose)
End SyncLock
End Sub
Any idea on what's happening or how to debug the issue? As the Start() is called without exception I expected to find the port always opened (the log is always written).
Extra information: when the Start method works fine it works each time until app is restarted. When the Start method does not work it won't work again until the app is restarted.
Edit: There is also an Stop method at the ExtendedTcpListener:
Public Shadows Sub [Stop]()
SyncLock (m_stopLock)
MyBase.Stop()
My.Application.Log.WriteEntry("... extended Tcp Listener stopped", TraceEventType.Verbose)
End SyncLock
End Sub
The class that uses the ExtendedTcpListener implements the IDisposable pattern and inside the Dispose the ExtendedTcpListener.Stop is called.
The stop text is not present at the logs when the problems happens.