UDP+binary+passive and prim_inet:recvfrom/3 bug?

Raimo Niskanen raimo@REDACTED
Mon Jan 8 09:39:00 CET 2001


Samuel Tardieu wrote:
> 
> On  5/01, Tony Rogvall wrote:
> 
> | From inet_drv.c
> |
> | /*
> | ** passive mode reply:
> | **        {inet_async, S, Ref, {ok,[H1,...Hsz | Data]}}
> | */
> |
> | This means that the inet_drv ADDs a header list of sz bytes. In this case
> | the header data is the Familiy, Port and Address, the rest my or may  not be a
> | binary.
> 
> However, the following code:
> 
> -module (bug).
> -export ([start_udp/0]).
> 
> start_udp () ->
>   {ok, U} = gen_udp:open (4161, [binary, {active, false}]),
>   io:format ("Received: ~p~n", [prim_inet:recvfrom (U, 1500)]),
>   erlang:halt ().
> 
> gives, when a UDP packet is received on port 4161:
> 
> {ok,<<1,12,73,127,0,0,1,0,6,1,0,0,1,0,0,0,0,0,0,6,102,111,111,98,97,114,0,0,1,0,1>>}
> 
> If the binary option is removed, it gives:
> 
> {ok,{{127,0,0,1},
>      3154,
>      [0,6,1,0,0,1,0,0,0,0,0,0,6,102,111,111,98,97,114,0,0,1,0,1]}}

The code in prim_inet is correct, but inet_drv.c needs some improvement.
We will look into this. It seems like the binary UDP case is not handled
correctly.

/ Raimo Niskanen, Ericsson Utvecklings AB - Erlang/OTP



More information about the erlang-questions mailing list