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


Groups > comp.lang.python > #26631

Re: Pickle file and send via socket

From Nobody <nobody@nowhere.com>
Subject Re: Pickle file and send via socket
Date 2012-08-06 17:11 +0100
Message-Id <pan.2012.08.06.16.11.55.540000@nowhere.com>
Newsgroups comp.lang.python
References <f3b73b0e-1520-4768-a1d2-bb754357dfc7@googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Mon, 06 Aug 2012 06:32:13 -0700, S.B wrote:

> Does anyone know if it's possible to pickle and un-pickle a file across
> a network socket. i.e: First host pickles a file object and writes the
> pickled file object to a client socket. Second host reads the pickled
> file object from the server socket and un-pickles it.

Yes, provided that the socket is a stream socket (e.g. TCP, Unix), not a
datagram socket (e.g. UDP).

> Can anyone provide a simple code example of the client and server sides?

Pickling via a socket is no different to pickling via a file. For a
socket, the .makefile() method will return a suitable file object.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-06 06:32 -0700
  Re: Pickle file and send via socket Nobody <nobody@nowhere.com> - 2012-08-06 17:11 +0100
  Re: Pickle file and send via socket Christian Heimes <lists@cheimes.de> - 2012-08-06 18:45 +0200
  Re: Pickle file and send via socket Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-06 15:26 -0400
  Re: Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-07 04:21 -0700
    Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-07 14:07 +0100
  Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 13:48 +0100
    Re: Pickle file and send via socket "S.B" <hyperboogie@gmail.com> - 2012-08-08 06:50 -0700
      Re: Pickle file and send via socket lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-08 16:07 +0100

csiph-web