[Tutor] using sockets to send a list

am@fx.ro am@fx.ro
Sat Feb 22 03:14:01 2003


On Fri, Feb 21, 2003 at 08:35:49PM -0600, Don Arnold wrote:
> # SERVER:
> 
> def sendinfo(self,player):
>    self.sockets[player].send(str(self.players),1024)
> 
> # CLIENT:
> 
> def getinfo(self):
>    dst = self.sock.recv(1024)
>    exec('self.players = %s' % dst)

It worked. Thanks!
The 'secret' was the str() function.

A had to do a few changes to the code above:
- i removed the second parameter (1024) of the send() function 
- it doesn't seem to be absolutely neccessary to use exec in the client:
   self.player=dst  has the same effect. 


Best wishes,

Adrian Maier
(am@fx.ro)