473,288 Members | 2,350 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,288 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 2532
"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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.