[erlang-questions] Newbie: Problem TCP connection erlang-python

Andreas Hillqvist <>
Thu Jan 31 14:08:53 CET 2008


Could it be the options?
You could try using {packet, raw}:
  Opts = [binary,
         {active,true},
         {packet, raw},
         {reuseaddr,true}],
  {ok, Listen} = gen_tcp:listen (Port, Opts),

See: http://www.erlang.org/doc/man/inet.html#setopts/2

Just some speculation from me. ;-)


Regards,
Andreas Hillqvist


2008/1/31, Gerald Kettlgruber <>:
> Hello,
> I have a problem concerning a tcp connection between an erlang server and a
> python client.
> The problem is, that on the server I receive the message, but the format
> doesn't match. I tried to specify the bits, but this doesn't worked either.
>
> This is what the server looks like:
> start(Port, Id) ->
>     {ok, Listen} = gen_tcp:listen (Port, [binary, {active,true},
> {reuseaddr,true}]),
>     accept(Listen, Id).
> accept(Listen, Id)->
>     {ok, Socket} = gen_tcp:accept(Listen),
>     gwe_server:start_agent(tcp_agent, accept, [Listen]),
>     loop(Socket, Id).
> loop(Socket, Id) ->
>     receive
>         {tcp, Socket, Bin} ->
>             <<To/integer, X/integer,Y/integer,Z/integer, W/integer>> = Bin,
>             loop(Socket, Id);
> end.
>
> Python Client looks like this:
>
> I pack the data with:
> data = [1,2,3,4,5]
> format= ">iiiii"
> msg = struct.pack(format,*data)
> size = struct.calcsize(format)
>
> and then send it with
> sent = self.sock.send(msg[totalsent:])
>
> Would be nice if anyone can help me.
> Thanks,
> Gerald Kettlgruber
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list