Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
do_get_remote_pid_tcp(Socket) when is_port(Socket) →
do_get_remote_pid_tcp(SockName) →
AllPorts = [{P, erlang:port_info(P)} || Perlang:ports()],
[Pid] = [
proplists:get_value(connected, I)
|| {P, I} ← AllPorts,
proplists:get_value(name, I) ≡ "tcp_inet",
inet:peername(P) ≡ SockName],
do_get_remote_pid_tls(Socket) →
%% This gives us the pid of the sslsocket process.
%% We must introspect this process in order to retrieve the connection pid.
TLSPid = do_get_remote_pid_tcp(ssl:sockname(Socket)),
{_, #state{user_application={_, UserPid}}} = sys:get_state(TLSPid),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.