Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Can't open /usr/share/games/fortunes/fortunes. Lid stuck on cookie jar.


devel / comp.lang.python / Re: Pickle file and send via socket

SubjectAuthor
* Re: Pickle file and send via socketUTKARSH PANDEY
`- Re: Pickle file and send via socketChris Angelico

1
Re: Pickle file and send via socket

<bcdfc36a-cdac-4179-af57-cd4335524997n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17074&group=comp.lang.python#17074

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:adf:fe0d:0:b0:1e3:3f5e:7469 with SMTP id n13-20020adffe0d000000b001e33f5e7469mr4586801wrr.61.1645160296680;
Thu, 17 Feb 2022 20:58:16 -0800 (PST)
X-Received: by 2002:ac8:5153:0:b0:2d0:e87c:8160 with SMTP id
h19-20020ac85153000000b002d0e87c8160mr5276637qtn.332.1645160296419; Thu, 17
Feb 2022 20:58:16 -0800 (PST)
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 17 Feb 2022 20:58:16 -0800 (PST)
In-Reply-To: <37mdnchk-JMqHb_NnZ2dnUVZ7tidnZ2d@bt.com>
Injection-Info: google-groups.googlegroups.com; posting-host=139.5.16.140; posting-account=JCsQ6QoAAAD7VvI1BWnbxIt_vqYFBLDP
NNTP-Posting-Host: 139.5.16.140
References: <f3b73b0e-1520-4768-a1d2-bb754357dfc7@googlegroups.com>
<WtqdncCw6amw_b_NnZ2dnUVZ7tGdnZ2d@bt.com> <674b1cd4-5f7d-47ce-924d-76f5306746bc@googlegroups.com>
<37mdnchk-JMqHb_NnZ2dnUVZ7tidnZ2d@bt.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <bcdfc36a-cdac-4179-af57-cd4335524997n@googlegroups.com>
Subject: Re: Pickle file and send via socket
From: u130519...@gmail.com (UTKARSH PANDEY)
Injection-Date: Fri, 18 Feb 2022 04:58:16 +0000
Content-Type: text/plain; charset="UTF-8"
 by: UTKARSH PANDEY - Fri, 18 Feb 2022 04:58 UTC

On Wednesday, August 8, 2012 at 8:37:33 PM UTC+5:30, lipska the kat wrote:
> On 08/08/12 14:50, S.B wrote:
> > On Wednesday, August 8, 2012 3:48:43 PM UTC+3, lipska the kat wrote:
> >> On 06/08/12 14:32, S.B wrote:
> >>
> [snip]
> > Thank you so much !
> > The examples are very helpful.
> > What happens if I have a regular text file I want to send via the network.
> > Do I need to read the file and then dump it into the "stargate" file object?
> Well according to the documentation at
>
> http://docs.python.org/py3k/tutorial/inputoutput.html#reading-and-writing-files
>
> it should be straightforward to read and write pickled files
> Not sure why you want to pickle a text file over the network when you
> could just stream it between ports !
>
> however ...
>
> I'm currently getting a Unicode decode error on the first byte in the
> stream when it gets to the other end, no idea why so I guess I have to
> continue searching, read the documentation above and see if you can
> figure it out, that's what I'm doing.
> lipska
>
> --
> Lipska the Kat: Troll hunter, sandbox destroyer
> and farscape dreamer of Aeryn Sun

Directly read bytes from file and send it over the socket object from client side in while loop until all content from file is read.

Something like this.

Client side
import socket

s = socket.socket()

PORT = 9898

s.connect(("192.168.0.101",PORT))

file = open("turnover.csv","rb")
SendData = file.read(1024)

while SendData:
s.send(SendData)
SendData = file.read(1024)

s.close()

Server side

import socket
s = socket.socket()
PORT =9898
print("Server is listening on port :",PORT,"\n")

s.bind(("192.168.0.101",PORT))

s.listen(10)

file = open("recv.csv","wb")
print("\n Copied file name will be recv.txt at server side\n")

while True:
conn,addr = s.accept()
RecvData = conn.recv(1024)
while RecvData:
file.write(RecvData)
RecvData = conn.recv(1024)

file.close()
print("\n File has been copied successfully \n")

conn.close()
print("\n Server is closing the connection \n")

break

Re: Pickle file and send via socket

<mailman.134.1645210808.7010.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17076&group=comp.lang.python#17076

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Pickle file and send via socket
Date: Sat, 19 Feb 2022 05:59:54 +1100
Lines: 10
Message-ID: <mailman.134.1645210808.7010.python-list@python.org>
References: <f3b73b0e-1520-4768-a1d2-bb754357dfc7@googlegroups.com>
<WtqdncCw6amw_b_NnZ2dnUVZ7tGdnZ2d@bt.com>
<674b1cd4-5f7d-47ce-924d-76f5306746bc@googlegroups.com>
<37mdnchk-JMqHb_NnZ2dnUVZ7tidnZ2d@bt.com>
<bcdfc36a-cdac-4179-af57-cd4335524997n@googlegroups.com>
<CAPTjJmqfHoar=96naCEY40MqWZfcpP4DzD+K-PG+TwV-Uks6+A@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 2gYzYPABGDQ7Y5X/HAtoXAo8jIsczctOJ7bZ5XWGR4Dg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=lSSimLis;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.029
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; '2022': 0.05; 'loop': 0.07;
'chrisa': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'impressive': 0.16; 'ping': 0.16; 'wrote:': 0.16;
'feb': 0.17; 'to:addr:python-list': 0.20; 'sat,': 0.22;
'subject:file': 0.22; 'object': 0.26; 'wednesday,': 0.26;
'message-id:@mail.gmail.com': 0.32; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'received:209.85': 0.37; 'file': 0.38; 'read': 0.38;
'received:209': 0.39; 'quite': 0.39; 'years.': 0.40; 'ten': 0.61;
'send': 0.63; 'time.': 0.66; 'content': 0.72; 'client': 0.82
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=DkMNXFTo2gtUgigl9vIBr/Ghn7Dcen/751QXFrVE+OY=;
b=lSSimLisdugLi5/NjNVKFxw/2O9aL/lCbqCc/pOmFk1ilc59RKflAzksoW+UHF4POD
Gx/+zfqtbuyqeapnRn7dg0VgsxhxfC4tPfiAwkiphOpwS9SyM1/38Cq3iyVi9PNV1ZRy
1sAUoEAVmzuG2ffFZGbf2hFjsPD4oWE1ehf+PlbUOEBgz65mbg2t3TXbAPwa1Kqya8s+
Nb22hKPoyySPbuMIv+IYjA8nyzRO5nYGCsMgrlQX0Q/lKRBWHgLrt0POosizUbwpqjqh
hhq+bJtHYiUBWEhwrZIeV8sscQc7RfI7T8sKGKB3Gwvpg1L2NisqL46UlW1NgVuTNimE
0SQA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=DkMNXFTo2gtUgigl9vIBr/Ghn7Dcen/751QXFrVE+OY=;
b=Ges0+THbh9jrbrAUc4tAoia9c+JBNQSbVidvcAMwaHQxamLrCUqUjYyzWUfntUoo8u
dL7wbvV2bE5n2HZMOp5hgCYdEnrFKusrx2J+5rrW2Usn5bTQ816cqgyiLAoK8O3+zeM+
HaAcYUb2+xrbRrFj6Mbsbiw2bjeiXtK91uGfF0BVe+HQ7giCq0TvJhJKRz/g/uQ6m8lK
ZjYVZ+6fGyhc9eLxrIlygOTFhXRngONW4485e5J4J1HAEvGQsuuRU6aLz+LKgiNKs3xR
GxFy85e89xUJIuEExXldQ/I0eQiTfn2ZlLBhxi3QRulEGMMDU7PIKfDadodYJwM7R7cK
1OIA==
X-Gm-Message-State: AOAM533R9ILWgaZgzJx1trpFRLVDH506WbydizZhZt7Dh5Ob79amryKH
imyGJkEE538K0oMRDVbGu38gUEPn+zs4KHK1z2TCqunH
X-Google-Smtp-Source: ABdhPJw0JHCjiTcZxGtLof0mVuY9HJk4QV5TspnI0pDssiiN0GijrvMxVcL6JOuUVQ4WLQXoyIwMcJUir5FYKvPLfbM=
X-Received: by 2002:a5d:408c:0:b0:1e3:23a9:799f with SMTP id
o12-20020a5d408c000000b001e323a9799fmr6861854wrp.104.1645210805358; Fri, 18
Feb 2022 11:00:05 -0800 (PST)
In-Reply-To: <bcdfc36a-cdac-4179-af57-cd4335524997n@googlegroups.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://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: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmqfHoar=96naCEY40MqWZfcpP4DzD+K-PG+TwV-Uks6+A@mail.gmail.com>
X-Mailman-Original-References: <f3b73b0e-1520-4768-a1d2-bb754357dfc7@googlegroups.com>
<WtqdncCw6amw_b_NnZ2dnUVZ7tGdnZ2d@bt.com>
<674b1cd4-5f7d-47ce-924d-76f5306746bc@googlegroups.com>
<37mdnchk-JMqHb_NnZ2dnUVZ7tidnZ2d@bt.com>
<bcdfc36a-cdac-4179-af57-cd4335524997n@googlegroups.com>
 by: Chris Angelico - Fri, 18 Feb 2022 18:59 UTC

On Sat, 19 Feb 2022 at 05:47, UTKARSH PANDEY <u13051995p@gmail.com> wrote:
>
> On Wednesday, August 8, 2012 at 8:37:33 PM UTC+5:30, lipska the kat wrote:
> > ...
> Directly read bytes from file and send it over the socket object from client side in while loop until all content from file is read.
>

Almost ten years. Quite an impressive ping time.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor