Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3584
| References | <61890800-f81a-4a1e-8905-a0237407f016@a21g2000prj.googlegroups.com> |
|---|---|
| Date | 2011-04-20 05:29 +1000 |
| Subject | Re: Pickling over a socket |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.580.1303241379.9059.python-list@python.org> (permalink) |
On Wed, Apr 20, 2011 at 4:53 AM, Roger Alexander <rtalexander@mac.com> wrote: > Hi, > > I'm trying to understand how to pickle Python objects over a TCP > socket. > > In the example below (based on code from Foundations of Python Network > Programming), a client creates a dictionary (lines 34-38) and uses > pickle.dump at line 42 to write the pickled object using file handle > make from a socket. The server de-pickles with pickle.load (line 24), > again using a file handle made from a socket. Whenever there's a problem, create simplicity. I would recommend not using the file-from-socket method, and simply using pickle.dumps() and pickle.loads() to pickle to/from strings; those strings can then be sent/received over the socket using standard recv/send functions. Also, Chris Rebert's idea is a good one, and worth trying. Chris Angelico
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Pickling over a socket Roger Alexander <rtalexander@mac.com> - 2011-04-19 11:53 -0700
Re: Pickling over a socket Chris Rebert <clp2@rebertia.com> - 2011-04-19 12:21 -0700
Re: Pickling over a socket Chris Angelico <rosuav@gmail.com> - 2011-04-20 05:29 +1000
Re: Pickling over a socket Dan Stromberg <drsalists@gmail.com> - 2011-04-19 12:30 -0700
Re: Pickling over a socket Chris Angelico <rosuav@gmail.com> - 2011-04-20 05:37 +1000
Re: Pickling over a socket Roger Alexander <rtalexander@mac.com> - 2011-04-19 15:27 -0700
Re: Pickling over a socket Jean-Paul Calderone <calderone.jeanpaul@gmail.com> - 2011-04-19 19:28 -0700
Re: Pickling over a socket Bastian Ballmann <balle@chaostal.de> - 2011-04-20 08:44 +0200
Re: Pickling over a socket Chris Angelico <rosuav@gmail.com> - 2011-04-20 16:59 +1000
Re: Pickling over a socket Bastian Ballmann <balle@chaostal.de> - 2011-04-20 09:34 +0200
Re: Pickling over a socket Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-04-20 10:25 +0200
[OT] Re: Pickling over a socket Bastian Ballmann <balle@chaostal.de> - 2011-04-20 10:59 +0200
Re: Pickling over a socket Chris Angelico <rosuav@gmail.com> - 2011-04-20 19:26 +1000
Re: Pickling over a socket Bastian Ballmann <balle@chaostal.de> - 2011-04-20 11:41 +0200
csiph-web