473,396 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What Data is Available With a Pickled Object Over a Socket?

I've read the library entry for pickle a couple of times, and I'm
still not
sure what data is maintained when an item is pickled and sent over a
socket.

Two importable modules:

class envelope():
def __init__(self, rec, d):
self.recipient = rec
self.listData = d

class mailbag():
def __init__(self):
self.dicEnvelope = []

def addEnvelope(self, uuid, envelope):
self.dicEnvelope[uuid] = envelope
Client
---------
import envelope, mailbag, cPickle, socket

remoteHost = "999.666.888.777
mb = mailbag()
env1 = envelope('John', ('a', 'b', 'c'))
env2 = envelope('Mary', ('d', 'e', f'))

mb.addEnvelope(1, env1)
mb.addEvenlop(2, env2)

pickledMailbag = cPickle.dump(mb, HIGHEST_PROTOCOL)

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(remoteHost)
sock.send(pickledMailbag)

Server
---------
import envelope, mailbag, cPickle, socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(host, port)
sock.listen(5)
conn, addr = sock.accept()
while 1:
pickledData = conn.recv(1024)
if not pickledData break

mb = cPickle.load(pickledData)

At this point, does mb contain a dictionary with the two envelopes
with
their data?

Oct 18 '07 #1
2 2539
"milan_sanremo" <hanco,,,ail.com>wrote:

>
pickledMailbag = cPickle.dump(mb, HIGHEST_PROTOCOL)
If you are going to send it over a socket - is it not better to use
dumps instead of dump?

- Hendrik

Oct 19 '07 #2
milan_sanremo <ha************@gmail.comwrote:
I've read the library entry for pickle a couple of times, and I'm
still not
sure what data is maintained when an item is pickled and sent over a
socket.
I would not do that if I were you:
<http://jcalderone.livejournal.com/15864.html>

Unless you don't care about security

--
Lawrence, oluyede.org - neropercaso.it
"It is difficult to get a man to understand
something when his salary depends on not
understanding it" - Upton Sinclair
Oct 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Crirus | last post by:
Hi all! I use a webClient for requesting data from a server of mine. Should I worry about long ammount of data sent by server in the client side? Or, another way, should I send some kind of a...
3
by: Nuno Magalhaes | last post by:
Hello, I've got a small application that tries to read HTML data without the HTTPWebResponse and Request methods and I guess the server is closing the connection after a while. Here is my...
7
by: Nuno Magalhaes | last post by:
I've got a problem which relates to reading HTTP data. I've got the socket connected to a web site and then I send "GET / HTTP/1.1\n\n" and the page is received after a while but not all of the...
0
by: Bram Stolk | last post by:
Hi there, I'm transfering small pickled object over a socket. The performance I see is lower than expected. How fast should I be able to ping/pong small objects in python? I use a threaded...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
2
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless...
10
by: Uma - Chellasoft | last post by:
Hai, I am new to VB.Net programming, directly doing socket programming. In C, I will be able to map the message arrived in a socket directly to a structure. Is this possible in VB.Net. Can...
4
by: awmcclain.nospam | last post by:
Here's my situation: I'm writing a simple reminder bot which will IM me based on input from a web server. Right now, I have a simple AIM bot written using twisted 2 words. It logs into AIM and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.