I'm trying to use Transport:controlling_process(Sock, NewPid) inside process spawned by esockd:open(..., MFArgs), but it fails when using UDP with badarg. Sock argument is from
|
loop(Transport = {udp, Server, Sock}, Peer = {IP, Port}) -> |
|
receive |
It seems that gen_udp:controlling_process is not implemented.
|
-spec(controlling_process(socket(), pid()) -> ok | {error, Reason} when |
|
Reason :: closed | not_owner | badarg | inet:posix()). |
|
controlling_process(Sock, NewOwner) when is_port(Sock) -> |
|
gen_tcp:controlling_process(Sock, NewOwner); |
|
controlling_process(#ssl_socket{ssl = SslSock}, NewOwner) -> |
|
ssl:controlling_process(SslSock, NewOwner); |
|
controlling_process(#proxy_socket{socket = Sock}, NewOwner) -> |
|
controlling_process(Sock, NewOwner); |
I can't simply use gen_udp:controlling_process() as workaround since socket is in a different process (error current process is not the owner of the socket)
I think we could fix it by updating the Pid assigned to a Peer with an exported function.
|
handle_info({udp, Sock, IP, InPortNo, Packet}, |
|
State = #state{sock = Sock, peers = Peers, access_rules = Rules}) -> |
|
case maps:find(Peer = {IP, InPortNo}, Peers) of |
|
{ok, Pid} -> |
|
Pid ! {datagram, self(), Packet}, |
|
{noreply, State}; |
I'm trying to use
Transport:controlling_process(Sock, NewPid)inside process spawned byesockd:open(..., MFArgs), but it fails when using UDP withbadarg.Sockargument is fromesockd/examples/udp/udp_echo_server.erl
Lines 34 to 35 in d0c3edc
It seems that
gen_udp:controlling_processis not implemented.esockd/src/esockd_transport.erl
Lines 89 to 96 in d0c3edc
I can't simply use
gen_udp:controlling_process()as workaround since socket is in a different process (errorcurrent process is not the owner of the socket)I think we could fix it by updating the
Pidassigned to aPeerwith an exported function.esockd/src/esockd_udp.erl
Lines 273 to 278 in d0c3edc