Quote Originally Posted by Mike Hildner
When you say "shuts down the connection and sockets", what's the code you're using?

Also, what's your Socket.Connect code? Make sure to create a new Socket before calling .Connect and not re-use the old Socket instance.

Mike
The code to close the extended TCPClient is below.
VB Code:
  1. Public Overloads Sub close()
  2.         Try
  3.             If (Me.Client.Connected) Then
  4.                 Me.Client.Shutdown(SocketShutdown.Both)
  5.                 Me.Client.Close()
  6.             End If
  7.  
  8.             Me.Client = Nothing
  9.             Me.Active = False
  10.  
  11.             ' double check
  12.             If (m_theSocket.Connected) Then
  13.                 m_theSocket.Shutdown(SocketShutdown.Both)
  14.                 m_theSocket.Close()
  15.             End If
  16.  
  17.             m_theSocket = Nothing
  18.         Catch e As Exception
  19.             el.WriteEntry("Client: Error closing connection - " & e.Message & vbCrLf & e.StackTrace)
  20.         End Try
  21.     End Sub

As for the connecting, after using an instance of my extended TCPClient once, I call the code above (its close() method), and then set the instance to Nothing. When I need it again for the second time, I create a new instance. The socket associated with the extended TCPClient is a member variable and is "new"'d with each call to connect() (and as you can see above, when close() is called, the socket is shutdown, closed, and set to Nothing).

I believe this is an acceptable way of doing things. It's the whole "two minutes" thing. I've read that Microsoft has some faulty port handling/releasing where it takes up to two minutes to clean up and release the port if its moved a fair bit of data, but that might just be conjecture. Any help that can be rendered would be most appreciated.

Cheers,
Duncan