Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3584

Re: Pickling over a socket

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'wed,': 0.04; 'socket': 0.05; 'dictionary': 0.07; 'method,': 0.07; 'python': 0.07; 'roger': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'simplicity.': 0.16; 'socket.': 0.16; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'foundations': 0.23; 'objects': 0.24; 'example': 0.24; "i'm": 0.26; 'chris': 0.27; 'object': 0.27; 'message- id:@mail.gmail.com': 0.28; 'hi,': 0.29; 'server': 0.29; 'functions.': 0.29; 'one,': 0.31; 'to:addr:python-list': 0.32; 'idea': 0.32; 'creates': 0.33; 'uses': 0.34; 'using': 0.34; 'file': 0.35; 'problem,': 0.35; 'received:209.85': 0.37; '20,': 0.38; 'apr': 0.38; 'strings': 0.38; 'received:google.com': 0.38; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'how': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'below': 0.63; 'worth': 0.64; '(based': 0.84; 'alexander': 0.84; 'received:209.85.210.174': 0.84; 'received:mail- iy0-f174.google.com': 0.84; 'subject:over': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=Hq2FgNxEzdUY6TzMoJNa/hPASZu6U73kl1ppyDASnPQ=; b=nFx2kmwk6K+W/q42oxMzc+WWsRM6oW5u/hyCEI53bzETZeZ7rHVDVt5JnvTU6JmQ1m nzmwu70Wbg1k/3aXkNxgpdZNLptdRS1+K2F9NTmHANvBl28ToJpUpq4Oq9EvtRzAH1S6 hB/vc+4h09/mJbjrjOprnX2vXZ3kZkofnGgko=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=vBHCCu9Anlsgy5pPKgcaU5Rl9qi4JqQHDb+tOzhVrbNRMdTmDPJ/fMXYCKwrV77T4r tVL7V8ABwSReLUJU0yatONA5/6jYEW8m4J+l+cc9Qm3+hr/UMWuyyV3TAZgmmz/RRxFS rr9O73++g5v/BcIaHRQljCUfGsHoFMClDlPm4=
MIME-Version 1.0
In-Reply-To <61890800-f81a-4a1e-8905-a0237407f016@a21g2000prj.googlegroups.com>
References <61890800-f81a-4a1e-8905-a0237407f016@a21g2000prj.googlegroups.com>
Date Wed, 20 Apr 2011 05:29:36 +1000
Subject Re: Pickling over a socket
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.580.1303241379.9059.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 82.94.164.166
X-Trace 1303241379 news.xs4all.nl 81483 [::ffff:82.94.164.166]:37773
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3584

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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