-1

I get socketexception that tell "connection reset" in the server side. this happen when Client side lost the connection to the server and re- connect.

what may I do to "fix" the socket. how to handle this Exception after it occur ... EDIT my question not need code, I ask about the concept of dealing with socketexception, the socket already closed or connection reset. my application supposed to be connected to the server all the time, we know that in any time of the app life the Registered client will lost the Internet access. then this exception will fire. How may I let the Client to reconnect!!

EsmaeelQash
  • 488
  • 2
  • 6
  • 20

1 Answers1

1

The idea is to fix the bug that causes it to happen. After it happens there is nothing you can do except close the socket. It's usually caused by writing to a connection that had already been closed b the peer: in other words, an application protocol error.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Ok, my app. that connected to the server is a mobile aplication, so, in some cases, the mobile will lost the internet connection, and when the mobile re-connect to the internet, it will try to connect to the server. so, how to prevent the exception?.. – EsmaeelQash Feb 16 '14 at 10:16
  • You *can't* prevent it. You can detect it, and recover from it. It sounds like you're already doing that. – user207421 Feb 16 '14 at 11:38
  • thx, you may help me with morr details. now the coonnection reset and I catch the exception how to continue. – EsmaeelQash Feb 16 '14 at 12:27
  • What part of 'close the socket' don't you understand? – user207421 Feb 16 '14 at 20:41