[Mono-list] UDP and ICMP
P Oscar Boykin
Thu, 5 Feb 2004 10:45:16 -0800
Content-Type: text/plain; charset=us-ascii
On Thu, Feb 05, 2004 at 11:21:15AM +0100, Marco Canini wrote:
> On Thu, 2004-02-05 at 05:41, P Oscar Boykin wrote:
> > Hello All.
> > I am using using mono to send udp packets between two hosts. At some
> > point, one host may go offline. If I watch the network (using ethereal)
> > I see the UDP packet go from A->B, and host B responds with a ICMP
> > destination unreachable packet. However, I don't see how I can get
> > access to that packet in my application.
> Sorry but if B goes down how do you see the ICMP packets from B?
Obviously if the host B is down, no ICMP packet will be sent from it.
However, if the program is closed, or crashes unexpectedly, the host is
still active, but no process is Binded to the socket, and thus the host
will reply with an ICMP packet.
> Anyway you can make B send UDP packets to A as an acknowledge, setting a
> timeout to wait for B responses in A
Sure, I could do more work using only UDP to have acknowledgements,
etc., however, in the cases where the ICMP is sent by B, I would like A
my program running on A to know about it.
There are APIs that throw errors when the ICMP message comes in. =20
For instance, in Java there is the PortUnreachableException:
It seems like people are saying that they think that A simply ignores
the ICMP message and the .Net framework has no way of passing that
information to the user (without being root and listening for the raw
In fact, when I look up this issue for winsock the following page
"UDP Behavior (Added 2001.03.26)
According to Ilpo Ruotsalainen, "...most BSD socket implementations do
not pass delayed UDP errors (ICMP port unreachable at least, maybe
others too) to recvfrom() while Winsock 2 [under Windows 2000 but not
Windows 98] does. Linux [behaves like Windows 2000] too, but provives
SO_BSDCOMPAT setsockopt() for being compatible with the BSD style."
In other words, a portable program has to be prepared for the
possibility of error codes for non-immediate problems from recvfrom(),
but it can't depend on receiving them."
This guy says Winsock 2 on win2000 throws a ECONNRESET error in this
This page also says the Winsock behavior is to give an error here:
And the .Net framework says it uses Winsock2 error codes:
I don't have access to a windows machine, but it seems like (from what I
have read) that the ReceiveFrom should throw an exception when the host
gets a "destination unreachable" ICMP message.
Can this be considered a bug?
email@example.com http://pobox.com/~boykin jabber: firstname.lastname@example.org
fingerprint=3DD250 4AD9 4544 B7D2 A17C 911D D608 D387 6718 D75F
Consumer Rights: http://www.consumerwatchdog.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
-----END PGP SIGNATURE-----