[erlang-questions] Question about gen_tcp:recv
Andrew Thompson
andrew@REDACTED
Tue Nov 1 21:31:09 CET 2011
On Tue, Nov 01, 2011 at 01:15:19PM -0700, flowerstars wrote:
> Hi guys,
>
> I am a beginner of learning erlang. My problem is whenever I call
> gen_tcp:recv, I got {error, closed} all the time.
>
> The procedure is as following:
>
> 1> Opts = [list, {packet, 0}, {active, false}, {reuseaddr, true}].
> [list,{packet,0},{active,false},{reuseaddr,true}]
> 2> {ok, Sock} = gen_tcp:connect("pop.gmail.com", 995, Opts).
> {ok,#Port<0.526>}
> 3> Res = gen_tcp:recv(Sock, 0).
> {error, closed}
>
> Is the problem about my code or about the pop server?
>
> Thanks so much for your reply.
>
995 is the SSL port for pop3, the server is probably waiting for the SSL
handshake. If you want this to work, you'll have to use the ssl:connect
function and friends.
Andrew
More information about the erlang-questions
mailing list