I'm using procket in combination with erlang:open_port/2 and erlang:port_close/1.
I'm polling the socket like here https://github.com/msantos/inert#busy-waiting
but instead of sleep and spin again on {error, eagain} I pass in active mode with erlang:open_port/2 and then after receiving a pkt I switch back to passive mode with erlang:port_close/1.
The problem is that when you use port_close the socket is set as BLOCKING and a call to procket:read/2 blocks until new data arrive.
This PR add a nif to set a socket non blocking.
I'm using procket in combination with
erlang:open_port/2
anderlang:port_close/1
. I'm polling the socket like here https://github.com/msantos/inert#busy-waiting but instead of sleep and spin again on{error, eagain}
I pass in active mode witherlang:open_port/2
and then after receiving a pkt I switch back to passive mode witherlang:port_close/1
. The problem is that when you useport_close
the socket is set asBLOCKING
and a call toprocket:read/2
blocks until new data arrive.