I am using a socket (System.Net.Sockets.TcpClient) to send a message. When I finish sending the message, I want to properly dispose of the socket.
Below is what I have:
Dim client As System.Net.Sockets.TcpClient
client = New System.Net.Sockets.TcpClient
client.Connect (IPAddress, Port)
networkStream = client.GetStream()
networkStream.Write(Data, 0, Data.Length)
networkStream = Nothing
client = Nothing
Is this the correct way to dispose of the socket, or am I missing something? There is not a .Dispose method on a TcpClient object, so close is the closest thing I have. Is disposing of the stream and then closing the socket all that is needed, or should I be doing something else?