[erlang-questions] Simple TCP Server

Ale <>
Wed Dec 18 20:33:22 CET 2013


>
>
> get_data(Device, Socket) ->
>   case io:get_line(Device) of
>     {ok, Data} ->
>       gen_tcp:send(Socket, Data),
>       get_data(Device, Socket);
>     eof ->
>       file:close(Device),
>       gen_tcp:close(Socket)
>   end.
>


from erl -man io

get_line(Prompt) -> Data | eof | {error, Reason}
get_line(IoDevice, Prompt) -> Data | eof | {error, term()}


get_line doesn't return {ok, Data}, also you may want to use
get_line(Device, "")

cheers,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131218/3b9f0395/attachment.html>


More information about the erlang-questions mailing list