[erlang-questions] enotconn from gen_tcp socket

Attila Rajmund Nohl <>
Fri Jun 8 15:50:58 CEST 2012


2012/6/8 Sergei Fomin <>:
> Hello.
>
> There is a server which gen_tcp:accept new connections and immediately logs
> inet:peername. But still, "Accepted {error,enotconn}" can be seen in the log
> files. One possible reason of such error is described in
> http://erlang.org/pipermail/erlang-questions/2012-May/066802.html , i.e. a
> client does 3-way handshake and sends RST packet immediately. Though, this
> scenario seems uncommon.
>
> Wonder, what other causes can lead to enotconn on just opened socket?

I think it doesn't have to be an RST, a normal connection closing
would also lead to this error. I've seen a very similar error a couple
of months ago when the OTP SFTP client did something similar as you,
i.e. it had a

{ok, PeerAddr} = inet:peername(Socket),

call soon after the Socket was created and sometimes this crashed with
a badmatch. The SFTP client has been fixed in R15B01, so there's a
case and error handling instead of the matching.



More information about the erlang-questions mailing list