Quantcast

Question about gen_tcp:recv

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about gen_tcp:recv

flowerstars
This post has NOT been accepted by the mailing list yet.
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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about gen_tcp:recv

Andrew Thompson-3
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


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about gen_tcp:recv

宋寒
Thanks Andrew, It works well.

Thank you so much. :)

2011/11/1 Andrew Thompson <andrew>

> 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
> _______________________________________________
> erlang-questions mailing list
> erlang-questions
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111101/f71ea4c3/attachment.html>

Loading...