[erlang-questions] inet_res:getbyname/2 and udp:connect/3

Per Hedeland per@REDACTED
Thu Jun 17 22:19:20 CEST 2010


Tony Rogvall <tony@REDACTED>
>
>On 17 jun 2010, at 00.33, Per Hedeland wrote:
>
>> Tony Rogvall <tony@REDACTED> wrote:
>>> Cool!
>>> send is failing on subsequent send, but recv is not ???? This is strange
>>> times.
>>
>> Erlang gen_udp:recv() is not failing.
>
>No, I meant it returned ok instead of {error, econnrefused}
>

Yes - I meant that it's gen_udp:recv() that is not failing (which it
should), as opposed to recv(2) not failing.

>> man inet_drv
>No manual entry for inet_drv

Wow, really?:-)

>I was thinking in terms of how to get connected UDP working on more than
>one platform.

Oh, I think it (i.e. with gen_udp) works on most of them - you already
verified on Darwin (AFAIK the VM uses select() there), and now I tried
Linux, Solaris, QNX(!) - and NetBSD... - works fine on all of them. That
last one had me a little surprised actually, so I also tried a different
build (of R13B03-ish) on FreeBSD - and that works fine too! I.e. it
seems this is actually a problem with the FreeBSD "port" build of
Erlang/OTP (I happened to have such a build of R12B-5 around too - same
problem there). Sorry for the noise.

FWIW, as you can see from the output of the obnoxious FreeBSD 'ktrace'
below, from doing gen_udp:recv() with the port build, inet_drv actually
gets the expected ECONNREFUSED on recvfrom(), but ignores it and does a
poll() anyway - which times out, of course. Some #ifdef or other flipped
the wrong way I guess, there are a few of them... - or maybe one of the
patches being applied in the port build that is broken.

--Per


 18895 beam     CALL  recvfrom(0x7,0x88818ec4,0x2000,0,0,0)
 18895 beam     RET   recvfrom -1 errno 61 Connection refused
 18895 beam     CALL  gettimeofday(0xbfbfd0f8,0)
 18895 beam     RET   gettimeofday 0
 18895 beam     CALL  gettimeofday(0xbfbfd9c4,0)
 18895 beam     RET   gettimeofday 0
 18895 beam     CALL  poll(0x88500c20,0x4,0x3e8)
 18895 beam     RET   poll 0
 18895 beam     CALL  gettimeofday(0xbfbfd9c8,0)
 18895 beam     RET   gettimeofday 0
 18895 beam     CALL  gettimeofday(0xbfbfe248,0)
 18895 beam     RET   gettimeofday 0
 18895 beam     CALL  ioctl(0,TIOCGWINSZ,0xbfbfe178)
 18895 beam     RET   ioctl 0
 18895 beam     CALL  write(0,0x88864000,0xf)
 18895 beam     GIO   fd 0 wrote 15 bytes
       "{error,timeout}"



More information about the erlang-questions mailing list