andrew4582

IsSocketConnected

Apr 14th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.34 KB | None | 0 0
  1.         private bool IsSocketConnected(Socket socket)
  2.         {
  3.             bool connectionNotClosedResetOrTerminated = !socket.Poll(1000, SelectMode.SelectRead);
  4.             bool socketHasDataAvailableToRead = (socket.Available != 0);
  5.             return (connectionNotClosedResetOrTerminated || socketHasDataAvailableToRead);
  6.         }
Advertisement
Add Comment
Please, Sign In to add comment