[erlang-questions] Peername of a closed TCP socket
Tue May 26 23:06:05 CEST 2009
You can try the inet option:
This will keep the port and the socket active so you can read
continue write data to a half open socket and possibly get the
peername, if that is available
by the underlying operating system.
You must then call gen_tcp:close to terminate the port/socket
On 26 maj 2009, at 17.39, Malcolm Dowse wrote:
> When a TCP client disconnects very soon after connecting to an
> Erlang server, is there any reliable way of getting the client's
> remote address?
> The inet:peername/1 function returns an error if the socket in
> question has closed. As a result, I can't find any better solution
> than to refactor the code so that inet:peername/1 is called as soon
> as possible after the gen_tcp:accept/1.
> Thanks in advance,
> erlang-questions mailing list
More information about the erlang-questions