471,350 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

A question about Socket.Close Method [C#] - misbehaviour in MSDN

Please see the Socket.Close page in MSDN.
There are such line in Remarks:

"The Close method closes the the remote host connection and releases all managed and unmanaged resources associated with the Socket.
Upon closing, the Connected property is set to false."

Please note the last (bold) sentence.
And see the example (on same page):
The following example closes a Socket.
[C#]
aSocket.Shutdown(SocketShutdown.Both);
aSocket.Close();
if (aSocket.Connected) {
Console.WriteLine("Winsock error: " + Convert.ToString(System.Runtime.InteropServices.Ma rshal.GetLastWin32Error()) );
}What is the sence of checking Connected property of the socket if a method line up will set this property false !
To my opinion the only reason is incorrect error hadling in method Close(). Why it doesn't throw an exception if it failed to do it's work?
Same in beta 2.0 doc.

Could some one describe this?

Jul 28 '05 #1
0 1464

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by sinan . | last post: by
4 posts views Thread by DreJoh | last post: by
1 post views Thread by Chris Morse | last post: by
4 posts views Thread by Haim | last post: by
reply views Thread by Macca | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.