[erlang-questions] Re: How to remove \ from string

Wes James comptekki@REDACTED
Thu Apr 7 05:39:33 CEST 2011


On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf
<muhammad.yousaf@REDACTED> wrote:
<snip>

one more way:

> Code is as fellow
> do_echo(Socket) ->
>     case gen_tcp:recv(Socket, 0) of
>         {ok, Data} ->

%             D = binary_to_list(Data),

             <<D:4/binary,_/binary>> = Data,
             case D of
                 <<"{get">> -> io:format("im
innnnnnn~n");%gen_tcp:send(Socket,erl_api:search());

>                 _Else -> io:format("im in none ~n")
>             end,
>             io:format("recieve Data from socket:~p~n",[D]),
>             do_echo(Socket);
>         {error, closed} ->
>             ok
>     end.

<<D:4/binary,_/binary> = Data

means get 4 bytes of Data and put in D

(each character is a byte, so grab first four and try a match in "case
of" statement)

-wes



More information about the erlang-questions mailing list