Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello all,

I am quite ne to socket, so forgive non-sense questions ...

I develop a tcp server on a Windows CE platform. I have created the server using simple Tcp Listenners, created the differents cleints, read write data to them, thank you code project.

Now i facing a problem, sometimes i get SocketException. My question is after getting a such exception what i have to do ?
I can suppose that sometime the socket is definitely dead, and sometimes, i can restart.

try
{
   this.MySocket.Send(...);
   this.MySocket.Receive(...);
} 
catch(SocketException ex)
{
   switch(ex.ErrorCode)
   {
       case ... :
          this.Retry();
          break;
       case ... : 
          this.MySocket.close();
          break;
    }
}



I have found all error code here, but how can i know ?

Romain TAILLANDIER
Posted

1 solution

About the only time you can successfully retry after a SocketException is in the event of a timeout error. For most other failures it is best to simply close the socket and try again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900