Isn't this what you are trying to do?
TcpClient.Close Method [Visual Basic]See Also
TcpClient Class | TcpClient Members | System.Net.Sockets Namespace | Close |
Shutdown | TcpClient Members (Visual J# Syntax) | Managed Extensions for C++
Programming Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003
family, .NET Compact FrameworkLanguage
C#
C++
JScript
Visual Basic
Show All
Closes the TCP connection and releases all resources associated with the
TcpClient.
[Visual Basic]
Public Sub Close()
[C#]
public void Close();
[C++]
public: void Close();
[JScript]
public function Close();
Exceptions
Exception TypeCondition
SocketExceptionAn error occurred when accessing the socket. See the Remarks
section for more information.
Remarks
The Close method closes the TCP connection. It calls the Dispose method
passing a true value to release all managed and unmanaged resources
associated with the TcpClient. These resources include the underlying Socket
used for connecting with the remote host, and the NetworkStream used to send
and receive data.
Note If you receive a SocketException, use SocketException.ErrorCode to
obtain the specific error code. Once you have obtained this code, you can
refer to the Windows Socket Version 2 API error code documentation in MSDN
for a detailed description of the error.
Example
[Visual Basic, C#, C++] The following example demonstrates closing a
TcpClient by calling the Close method.
[Visual Basic]
Dim tcpClientD As New TcpClient(AddressFamily.InterNetwork)
' Uses the Close public method to close the network stream and socket.
tcpClient.Close()
End Sub 'MyTcpClientCommunicator
"Haim" <ha**@spetrotec.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
it is very strange for me that a simple event of closing socket that was
in the the winsock object of vb6 ,
i didn't found yet in the vb.net
the only way i found is to try to send something to the socket and if i
got error then the socket is closed.
there must be a way to get this event without trying to send something ,
since it is in the lower level
can you advice please,
thanks in advance,
Haim.