NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Socket.Close

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;

Return Value

0 if the socket was successfully closed; otherwise a non-zero error code.

Remarks

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.

Example [C#]

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()) );

}

See Also

Socket Class | Socket Members | System.Net.Sockets Namespace