Hi,

I think you are doing a connect with the UDP socket that ties the two 
ends together. What you are seeing is proper IP behavior. When a UDP 
packet is sent to a port on which nothing is listening, the receiver 
will send an ICMP port-unreachable packet to the sender. Since you are 
using a connected UDP socket, the socket catches that ICMP packet and 
the subsequent recv raises an exception. An unconnected socket will 
ignore the ICMP packet.

You have a two options:

1. do not issue 'connect' with the UDP socket. ICMP replies will be 
ignored and you can also use one socket to communicate with multiple 
hosts and ports. You will want to use a non-blocking mechanism like 
Kernel::select with a timeout, or you can be waiting forever for a 
reply that may never come.

2. Catch the exception (since it is normal, you can use it to detect if 
your expected peer has dropped off). In this case you may also want to 
use Kernel::select since the other side may not see your packet or you 
may not see theirs (in the case that the peer is there but the packet 
dropped).

Dan


On May 19, 2004, at 10:30, <greg.burri / net2000.ch> wrote:

>
>
> -----Original Message-----
> From: ts <decoux / moulon.inra.fr>
> To: ruby-talk / ruby-lang.org (ruby-talk ML)
> Date: Wed, 19 May 2004 23:23:14 +0900
> Subject: Re: UDP Asynchrone connection problems
>
>>>>>>> "g" ==   <greg.burri / net2000.ch> writes:
>>
>> g> "WSAECONNRESET
>>
>>  You don't say what is your sytem : I suppose Windows, no ?
>>
>>  but which windows ?
>>
>>    http://support.microsoft.com/default.aspx?scid=kb;EN-US;263823
>>
>>
>> Guy Decoux
>>
>
> Sorry, the problem appears under windows (XP + ruby 1.8) and linux 
> (debian
> + ruby1.7). (the reception of this ICMP packet is normal)
>
>