Forces a socket connection to close.
[Visual Basic] Public Function Close() As Integer [C#] public int Close(); [C++] public: int Close(); [JScript] public function Close() : int;
0 if the socket was successfully closed; otherwise a non-zero error code.
The Connected property is set to false when the socket is closed.
The application should call Shutdown before calling Close to assure that all data is sent or received on the socket before the socket is closed.
If there is a problem closing the socket, Close will return a non-zero value indicating the error. The following code attempts to close a socket. If the attempt is unsuccessful, the error code is written to the console.
[C#]
result = aSocket.Close(); if (result <> 0) { Console.WriteLine("Winsock error: " + Convert.ToString(Marshal.GetLastWin32Error()) ); }
Socket Class | Socket Members | System.Net.Sockets Namespace