Re: Tcp Socket Close Event

From: Brian Henry (brian.henry[nospam)
Date: 04/04/04


Date: Sun, 4 Apr 2004 14:53:36 -0400

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" <haim@spetrotec.com> wrote in message
news:%23YJ3uAjGEHA.264@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.
>
>



Relevant Pages

  • Re: Socket.Disconnect Method
    ... Although the exception list in the MSDN documentation ... Windows XP SP2. ... An error occurred when attempting to access the socket. ... use the SocketException.ErrorCode property to obtain the specific error code. ...
    (microsoft.public.vsnet.general)
  • RE: Need help using tcpClient and tcpListner
    ... even the connect property of the socket doesn't give current ... > deriving from TcpClient can use this property to get or set this Socket. ... > Public Sub New ... > Dim localhostAddress As IPAddress ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Socket.Disconnect Method
    ... method that only worked on platforms prior to Windows ... method is supported on Windows 2000 and Windows 98, ... An error occurred when attempting to access the socket. ... It looks to me like the underlying error code could have been: ...
    (microsoft.public.vsnet.general)
  • RE: Best design pattern for a TCP "HUB" service
    ... For the maximum socket a TCPLister can accept, in theory it is 2^32-1, we ... In Socket programming, we have another term named backlog, which means the ... Use the Start method to begin listening for incoming connection requests. ... Windows Sockets server applications generally create a socket and then use ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sockets on Windows and Mac
    ... > I am new to Python and have been writing some socket based programmes ... > on Windows, however I am unable to get them to work ... > on Mac. ...
    (comp.lang.python)