[Spread-users] spread Communication Protocol

wglin122 wglin122 at gmail.com
Wed Apr 9 03:21:12 EDT 2008

I am a green hand of spread and now learning spread Communication Protocol
I'm writing a spread client by python which is try to connect to the
spread server.
Now I have several problems of Spread communication with python.Please
help me to make the connect protocol right.
Thanks a lot!

My python code of client:

import sock,struct
p = struct.pack('!5B4s',4,0,0,1,len('juny'),'juny')
msg = sock.recv(1)
l = ord(msg)
msg = sock.recv(l)
buffer = [ord(m) for m in msg]
sendAuthMethod = [0,]*90
for i in xrange(len(buffer)):
sendAuthMethod[i] = buffer[i]
p = struct.pack('!90B',*sendAuthMethod)
msg = sock.recv(1)
l = ord(msg)
#read Version
majorVersion = sock.recv(1)
majorVersion = ord(majorVersion)
minorVersion = sock.recv(1)
minorVersion = ord(minorVersion)
patchVersion = sock.recv(1)
#read group
msg = sock.recv(1)
grouplen = ord(msg)
msg = sock.recv(grouplen)
print msg

these codes above return #juny#machine1
I thins it means successful connection .
But then I try to join into a group and receive message fail.
Spread server daemon is alive and there is lots of message
So i think my join-group protocol code is wrong

My join-group python code:
group = 'purge_gz'
tag = '!4b32s4i4i4i32s'
# service type private group group num hint datelen group name
buffer = [0, 1, 0, 0, '#test#machine1', 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, group ]

p = struct.pack('!1s',' ')
buffer =sock.recv(48)

buffer info tells me:
group_num =1
data_len = 56
i try Read in the group names.
buffer =sock.recv(32)
is wrong !

If there is not problem in these codes,Could you please tell me where
the problem maybe?
Or coud you please tell me how to connent a server by python correctly
by step.

By the way,my spread version is 4.0.0.

Wait for your guidance ,thanks a lot!
my english is poor ,Understanding :)

More information about the Spread-users mailing list