[erlang-questions] Get a large string by socket

Jose Enrique Benitez Jimenez jebenitez@REDACTED
Wed Apr 22 21:51:56 CEST 2009


Hello friends, 

This code receive a string by socket ( {tcp, Socket_, Bin} ), but the
string is too large so it just get a piece of it, but I need get it all,
Do any of you have an idea for do that in a simple way? 

 

net_loop(Socket, Function, State, From)->

                receive

                               {connect, Host, Port}->

                                               {ok, Socket_} =
gen_tcp:connect(Host, Port, [list, {packet, 0}]),

                                               net_loop(Socket_,
Function, connected, From);

                               {send, Data, From_}->

                                               gen_tcp:send(Socket,
Data),

                                               net_loop(Socket,
Function, State, From_);

                               {tcp, Socket_, Bin} ->

                                               From ! {respuesta,Bin},

                                               net_loop(Socket_,
Function, State, From);

                               {tcp_closed, Socket_}->

                                               gen_tcp:close(Socket_)


                end.

 

% Thanks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090422/354cc766/attachment.htm>


More information about the erlang-questions mailing list