[erlang-questions] Newbie: Problem TCP connection erlang-python
Gerald Kettlgruber
kettlgruber@REDACTED
Thu Jan 31 14:36:33 CET 2008
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
More information about the erlang-questions
mailing list