msantos / procket

Erlang interface to low level socket operations
http://blog.listincomprehension.com/search/label/procket
BSD 3-Clause "New" or "Revised" License
283 stars 80 forks source link

Example fails on OSX #26

Closed philipcristiano closed 8 years ago

philipcristiano commented 8 years ago

Running the example

1> {ok, FD} = procket:open(53, [{protocol, udp},{type, dgram},{family, inet}]).
{ok,9}
2> {ok, S} = gen_udp:open(53, [{fd,FD}]).
{ok,#Port<0.929>}

seems to give me an error on OSX

1> {ok, FD} = procket:open(53, [{protocol, udp},{type, dgram},{family, inet}]).
{ok,14}
2> {ok, S} = gen_udp:open(53, [{fd,FD}]).
** exception error: no match of right hand side value {error,einval}

When trying on a variety of ports. Is this expected to work on OSX?

msantos commented 8 years ago

@philipcristiano definitely, OSX is a supported platform.

Are the erlang versions the same in the two examples? I think there was a change that required specifiying a port of 0 when passing in an fd. Try doing:

{ok, FD} = procket:open(53, [{protocol, udp},{type, dgram},{family, inet}]),
{ok, S} = gen_udp:open(0, [{fd,FD}]).
philipcristiano commented 8 years ago

@msantos ah cheers! That solved it.

2> {ok, S} = gen_udp:open(0, [{fd,FD}]).
{ok,#Port<0.4118>}

Thanks for the quick support!