SocketException.ErrorCode
(1)
SocketException
(1)
BeginReceive
(1)
Callback
(1)
UdpClient.BeginReceive
(1)
Receive
(1)
BeginRecieve
(1)
Newsbeitrag
(1)

SocketException question

Asked By Rainer Queck
17-Jul-08 08:50 AM
Hello NG,

in my application I get a SocketException in my receive callback method, if
the remote socket closes.
What would be the right way to treat this exception?

I want to keep my socket working, so that I can continue to receive
messages from the remote application, as it comes back online.
My problem at the moment is, that if I call  the udpClient.BeginReceive in
this moment, I again get the SocketException and from now on can't receive
any more messages on the socket.

Thanks for help and infos.

Regards
Rainer Queck

SocketException question

Asked By Pavel Minaev
19-Jul-08 10:30 PM
if

Technically, a remote UDP socket cannot "close" from your perspective,
since there's no established connection channel as such.


Depends on what the exception is, really...what is
SocketException.ErrorCode for the one you get?

SocketException question

Asked By Rainer Queck
17-Jul-08 09:12 AM
Hello Pavel,

Technically, a remote UDP socket cannot "close" from your perspective,
since there's no established connection channel as such.


Depends on what the exception is, really...what is
SocketException.ErrorCode for the one you get?
The error code is 10054 and the message - translated from german - is:

Rainer

SocketException question

Asked By Pavel Minaev
19-Jul-08 10:30 PM
Hm... apparently, if you do a Send, and get the "ICMP port
unreachable" response, this manifests itself as an error on the next
Receive you try to do on the same socket.  MSDN claims that a socket
is unusable once that happens, so you may have to recreate it entirely
on the same endpoint (once the client goes back online, it shouldn't
make any difference anyway, so long as the endpoint is the same).
SocketException question
Asked By Rainer Queck
17-Jul-08 09:56 AM
Hello Pavel,

Hm... apparently, if you do a Send, and get the "ICMP port
unreachable" response, this manifests itself as an error on the next
Receive you try to do on the same socket.  MSDN claims that a socket
is unusable once that happens, so you may have to recreate it entirely
on the same endpoint (once the client goes back online, it shouldn't
make any difference anyway, so long as the endpoint is the same).
Basically I understand what you say, but...
If I start my app and send a udp message to a port which is not opened
(yet) I  do get the socket exception (10054).
The confusing part is, that in this case I can call the
udpClient.BeginReceive within the Callback Method, without causing another
SocketException.

If a connection was establische, and then the remote socke closes I can't
call BeginRecieve without causing another (10054).
Why is that?

Regards
Rainer
Post Question To EggHeadCafe