Re: Pickle file and send via socket

2022-02-18 Thread Chris Angelico
On Sat, 19 Feb 2022 at 05:47, UTKARSH PANDEY 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. &

Re: Pickle file and send via socket

2022-02-18 Thread UTKARSH PANDEY
> 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

Re: How to set up a 'listening' Unix domain socket

2021-03-22 Thread Robert Latest via Python-list
n doesn't say so. I've noticed that when the server is not running, logging.SocketHandler creates the socket. I don't understand why it would; isn't it the server's job to create the socket? ## CLIENT #### import socket import pic

Re: How to set up a 'listening' Unix domain socket

2021-03-22 Thread Robert Latest via Python-list
Chris Angelico wrote: > > Hmm, your formatting's messed up, but the code looks fine to me. (Be aware > that you seem to have a "selr" where it should be "self".) Didn't catch that because my program didn't even get to that point ;-) > >> Howev

Re: How to set up a 'listening' Unix domain socket

2021-03-22 Thread Chris Angelico
On Mon, Mar 22, 2021 at 9:11 PM Robert Latest via Python-list wrote: > > Hello, > > I'm trying to set up a server that receives data on a Unix domain socket using > the code below. > > import os from socketserver import UnixStreamServer, StreamRequestHandler >

How to set up a 'listening' Unix domain socket

2021-03-22 Thread Robert Latest via Python-list
Hello, I'm trying to set up a server that receives data on a Unix domain socket using the code below. import os from socketserver import UnixStreamServer, StreamRequestHandler SOCKET = '/tmp/test.socket' class Handler(StreamRequestHandler): def handle(self): data = selr.rfi

Re: Any socket library to communicate with kernel via netlink?

2019-11-20 Thread Ian Pilcher
On 11/18/19 9:23 PM, lampahome wrote: As title, I tried to communicate with kernel via netlink. But I failed when I receive msg from kernel. The weird point is sending successfully from user to kernel, failed when receiving from kernel. So I want to check code in 3rd library and dig in, but alw

Any socket library to communicate with kernel via netlink?

2019-11-18 Thread lampahome
As title, I tried to communicate with kernel via netlink. But I failed when I receive msg from kernel. The weird point is sending successfully from user to kernel, failed when receiving from kernel. So I want to check code in 3rd library and dig in, but always found library called netlinkg but it

Re: python socket dns query will get the correct result while the dig will not.

2019-10-02 Thread Manfred Lotz
On Wed, 2 Oct 2019 04:27:14 + (UTC) Hongyi Zhao wrote: > Hi, > > See my following test: > > With ipython: > > In [1]: import > socket > > In [2]: socket.gethostbyname > ('www.vpngate.net&#x

Re: python socket dns query will get the correct result while the dig will not.

2019-10-01 Thread Chris Angelico
On Wed, Oct 2, 2019 at 4:41 PM Hongyi Zhao wrote: > > On Wed, 02 Oct 2019 16:28:40 +1000, Chris Angelico wrote: > > > When you ask dig, you are always asking for a DNS lookup. But > > gethostbyname does a lot of other things too. > > What other things, could you please give more detailed hints? S

Re: python socket dns query will get the correct result while the dig will not.

2019-10-01 Thread Hongyi Zhao
On Wed, 02 Oct 2019 16:28:40 +1000, Chris Angelico wrote: > When you ask dig, you are always asking for a DNS lookup. But > gethostbyname does a lot of other things too. What other things, could you please give more detailed hints? > My guess is that your > /etc/hosts has an entry for that doma

Re: python socket dns query will get the correct result while the dig will not.

2019-10-01 Thread Chris Angelico
On Wed, Oct 2, 2019 at 2:31 PM Hongyi Zhao wrote: > > Hi, > > See my following test: > > With ipython: > > In [1]: import > socket > > In [2]: socket.gethostbyname > ('www.vpngate.net') > Out[2]: '130.158.75.44' > > > With

python socket dns query will get the correct result while the dig will not.

2019-10-01 Thread Hongyi Zhao
Hi, See my following test: With ipython: In [1]: import socket In [2]: socket.gethostbyname ('www.vpngate.net') Out[2]: '130.158.75.44' With dig: $ dig www.vpngate.net @11

Re: Fwd: socket: Too many open files

2018-10-14 Thread Cameron Simpson
our data centers. Also, I am using commands module to get the traceroute output. out = commands.getstatusoutput('traceroute ' + ip) However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. [...] In fact, given that it is file d

Fwd: socket: Too many open files

2018-10-14 Thread Shakti Kumar
centers. >>Also, I am using commands module to get the traceroute output. >> >>out = commands.getstatusoutput('traceroute ' + ip) >> >>However I observe that this particular line is failing with socket error >>after I reach some 5k to 6k hosts. >>I

Re: socket: Too many open files

2018-10-13 Thread Cameron Simpson
commands module to get the traceroute output. out = commands.getstatusoutput('traceroute ' + ip) However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. I know commands module is using pipes to execute the given command and this is one

Re: socket: Too many open files

2018-10-13 Thread jfine2358
Hi Shakti You wrote: > out = commands.getstatusoutput('traceroute ' + ip) The page https://docs.python.org/3/library/subprocess.html#legacy-shell-invocation-functions describes subprocess.getstatusoutput as one of the "legacy functions from the 2.x commands module. These operations implicitly

Fwd: socket: Too many open files

2018-10-13 Thread Shakti Kumar
e traceroute output. >out = commands.getstatusoutput('traceroute ' + ip) >However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. >I know commands module is using pipes to execute the given command and this is one reason for exhau

socket: Too many open files

2018-10-13 Thread Shakti Kumar
. out = commands.getstatusoutput('traceroute ' + ip) However I observe that this particular line is failing with socket error after I reach some 5k to 6k hosts. I know commands module is using pipes to execute the given command and this is one reason for exhaustion of file descri

Re: asyncio await different coroutines on the same socket?

2018-10-05 Thread Russell Owen
On Oct 3, 2018, Ian Kelly wrote (in article): > On Wed, Oct 3, 2018 at 7:47 AM Russell Owen wrote: > > Using asyncio I am looking for a simple way to await multiple events where > > notification comes over the same socket (or other serial stream) in > > arbitrary > >

Re: asyncio await different coroutines on the same socket?

2018-10-03 Thread Ian Kelly
On Wed, Oct 3, 2018 at 7:47 AM Russell Owen wrote: > Using asyncio I am looking for a simple way to await multiple events where > notification comes over the same socket (or other serial stream) in arbitrary > order. For example, suppose I am communicating with a remote device that

Re: asyncio await different coroutines on the same socket?

2018-10-03 Thread Léo El Amri via Python-list
Hello Russell, On 03/10/2018 15:44, Russell Owen wrote: > Using asyncio I am looking for a simple way to await multiple events where > notification comes over the same socket (or other serial stream) in arbitrary > order. For example, suppose I am communicating with a remote device

asyncio await different coroutines on the same socket?

2018-10-03 Thread Russell Owen
Using asyncio I am looking for a simple way to await multiple events where notification comes over the same socket (or other serial stream) in arbitrary order. For example, suppose I am communicating with a remote device that can run different commands simultaneously and I don't know

Re: socket: Did I find a bug?

2018-03-08 Thread dieter
Antoon Pardon writes: > This is on a debian 9 box python 2.7.13 > > My interpretation is that a timeout exception is thrown and that the > args attribute of such an exception is an empty tuple which then causes > an IndexError in line 482 of module /usr/lib/python2.7/socket.py. Does > that soundpl

Re: socket: Did I find a bug?

2018-03-08 Thread INADA Naoki
https://mail.python.org/pipermail/python-list/2016-February/703154.html On Thu, Mar 8, 2018 at 8:09 PM, Antoon Pardon wrote: > This is on a debian 9 box python 2.7.13 > > My interpretation is that a timeout exception is thrown and that the > args attribute of such an exception is an empty tuple w

socket: Did I find a bug?

2018-03-08 Thread Antoon Pardon
This is on a debian 9 box python 2.7.13 My interpretation is that a timeout exception is thrown and that the args attribute of such an exception is an empty tuple which then causes an IndexError in line 482 of module /usr/lib/python2.7/socket.py. Does that soundplausible? Here is the traceback:

Re: python server socket file transfer

2018-01-10 Thread dieter
716 kb >> > ... >> > self.sock.send(l) >> >> Please read the documentation for *send* in the "socket" module: >> it tells you that "send" (in contrast to "sendall") is *not* guarantied >> to send the complete *l* (there is no g

Re: python server socket file transfer

2018-01-10 Thread bingbong3334
gt; > Please read the documentation for *send* in the "socket" module: > it tells you that "send" (in contrast to "sendall") is *not* guarantied > to send the complete *l* (there is no guarantee how much is sent); > the return value of "send" tells

Re: python server socket file transfer

2018-01-09 Thread dieter
bingbong3...@gmail.com writes: > how much client can i handel whit this code what the amount of client that i > can handel > the size of the file is 716 kb > ... > self.sock.send(l) Please read the documentation for *send* in the "socket" module: it tells you that "

python server socket file transfer

2018-01-09 Thread bingbong3334
how much client can i handel whit this code what the amount of client that i can handel the size of the file is 716 kb import socket from threading import Thread from SocketServer import ThreadingMixIn ## TCP_IP = '' TCP_PORT = 3156 BUFFER_SIZE = 1024 class ClientThread(Thread): de

Tcp Socket Receive

2017-04-02 Thread specx
Hello, � I have a tcp server coded with python and my packets include a 2 bytes header which is just the length of the following data. The problem is how can I be sure I received 2 bytes and not just one byte. In Qt, I use bytesAvailable function. However, here I just use sock.recv(2) but it can

Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Ethan Furman
On 01/23/2017 09:00 AM, Grant Edwards wrote: On 2017-01-23, Antoon Pardon wrote: The standard response to issues like this is: A foolish consistency is the hobgoblin of little minds And wise consistency is the foundation of a good language design. Otherwise known as: if there's not a

Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Grant Edwards
On 2017-01-23, Antoon Pardon wrote: > Op 22-01-17 om 01:52 schreef Grant Edwards: >> Newsgroups: gmane.comp.python.general >> From: Grant Edwards >> Subject: Re: How to create a socket.socket() object from a socket fd? >> References: >> >> >> Fol

Re: How to create a socket.socket() object from a socket fd?

2017-01-23 Thread Antoon Pardon
Op 22-01-17 om 01:52 schreef Grant Edwards: > Newsgroups: gmane.comp.python.general > From: Grant Edwards > Subject: Re: How to create a socket.socket() object from a socket fd? > References: > > > Followup-To: > > > > I'm still baffled why the sta

Re: How to create a socket.socket() object from a socket fd?

2017-01-22 Thread Christian Heimes
gt;> The module correctly detects address family, socket type and proto from >> a fd. It works correctly with e.g. IPv6 or Unix sockets. Ticket >> https://bugs.python.org/issue28134 has additional background information >> on the matter. > > Yes, thanks! > > Ju

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
Newsgroups: gmane.comp.python.general From: Grant Edwards Subject: Re: How to create a socket.socket() object from a socket fd? References: Followup-To: I'm still baffled why the standard library fromfd() code dup()s the descriptor. According to the comment in the CPython sources

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Christian Heimes wrote: > You might be interested in my small module > https://pypi.python.org/pypi/socketfromfd/ . I just releases a new > version with a fix for Python 2. Thanks for the hint! :) > > The module correctly detects address family, socket type and pr

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Chris Angelico wrote: > On Sun, Jan 22, 2017 at 9:41 AM, Grant Edwards > wrote: >> | __init__(self, family=2, type=1, proto=0, _sock=None) >> | >> >> Ah! There's a keyword argument that doesn't appear in the docs, so >> let's try that... > > That's marginally better than my monke

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Peter Otten
Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() > > Based on the docs, one might think that socket.fromfd() would do that > (since the docs

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Christian Heimes
On 2017-01-21 23:41, Grant Edwards wrote: > On 2017-01-21, Grant Edwards wrote: > >> Given a Unix file discriptor for an open TCP socket, I can't figure >> out how to create a python 2.7 socket object like those returned by >> socket.socket() >> >>

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Chris Angelico
On Sun, Jan 22, 2017 at 9:41 AM, Grant Edwards wrote: > | __init__(self, family=2, type=1, proto=0, _sock=None) > | > > Ah! There's a keyword argument that doesn't appear in the docs, so > let's try that... That's marginally better than my monkeypatch-after-creation suggestion, but still broad

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
On 2017-01-21, Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() > > Based on the docs, one might think that socket.fromfd() would do that > (si

Re: How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Chris Angelico
On Sun, Jan 22, 2017 at 9:28 AM, Grant Edwards wrote: > Given a Unix file discriptor for an open TCP socket, I can't figure > out how to create a python 2.7 socket object like those returned by > socket.socket() I suspect you can't easily do it. In more recent Pythons, yo

How to create a socket.socket() object from a socket fd?

2017-01-21 Thread Grant Edwards
Given a Unix file discriptor for an open TCP socket, I can't figure out how to create a python 2.7 socket object like those returned by socket.socket() Based on the docs, one might think that socket.fromfd() would do that (since the docs say that's what it does): Quoting https://docs.

Re: Socket programming

2016-09-26 Thread haaruunibrow
use > client: > server_address='192.168.2.2' server: > server_name='127.0.0.1' -- https://mail.python.org/mailman/listinfo/python-list

Re: python3: why writing to socket require bytes type while writing to a file require str ?

2016-07-22 Thread Steven D'Aprano
On Fri, 22 Jul 2016 06:52 pm, Yubin Ruan wrote: > Hi, > I'm migrating my code to python3 now and find it hard to deal with > python's 'str' and 'bytes' type. It's kind of painful. One thing I > find really confusing is that, writing to

Re: python3: why writing to socket require bytes type while writing to a file require str ?

2016-07-22 Thread Frank Millman
"Yubin Ruan" wrote in message news:47f3acf9-8da2-4aad-a6f0-7a9efbdfe...@googlegroups.com... In my understanding, writing to a file would requires that everything be written byte by byte. So writing objects of type 'bytes' to socket makes sense. But, how could python

Re: python3: why writing to socket require bytes type while writing to a file require str ?

2016-07-22 Thread Chris Angelico
On Fri, Jul 22, 2016 at 6:52 PM, Yubin Ruan wrote: > In my understanding, writing to a file would requires that everything be > written byte by byte. So writing objects of type 'bytes' to socket makes > sense. But, how could python write to file using unicode(type &#x

python3: why writing to socket require bytes type while writing to a file require str ?

2016-07-22 Thread Yubin Ruan
Hi, I'm migrating my code to python3 now and find it hard to deal with python's 'str' and 'bytes' type. It's kind of painful. One thing I find really confusing is that, writing to a socket requires argument to be of type 'bytes'(otherwi

Help: Python socket unit test framework

2016-07-05 Thread Harsh Gupta
Hello All, I have been trying to write a test framework for a pretty simple command server application in python. I have not been able to figure out how to test the socket server. I would really appreciate if you could help me out in testing this application using unittest. Please kindly

Re: Using SSL socket as stdin for subprocess.Popen

2016-03-22 Thread dieter
Matt Ruffalo writes: > ... > I've been using SSL for the communication between the client and server, > ... > I've hit an issue that I'm not sure how to work through, though. I'm > attempting to use a SSL socket (and/or the result of its 'makefile'

Re: Using SSL socket as stdin for subprocess.Popen

2016-03-21 Thread Chris Angelico
On Sun, Mar 20, 2016 at 4:44 AM, Matt Ruffalo wrote: > Hi all- > > I'm writing a backup client for automating the synchronization of btrfs > snapshots between machines -- essentially piping the output of `btrfs > send` on my laptop/desktop to `btrfs receive` on a server. I've been > doing this man

Using SSL socket as stdin for subprocess.Popen

2016-03-21 Thread Matt Ruffalo
n to verifying the client certificates against a trusted CA, this also allows things like selecting the backup destination based on the common name in the client cert. I've hit an issue that I'm not sure how to work through, though. I'm attempting to use a SSL socket (and/or the result o

RE: Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
> I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > [...] > > How is the best way to decode such reply from server? >https://docs.python.org/3/library/struct.html#examples

Re: Remote Rsponse Socket Connection

2016-03-11 Thread Marko Rauhamaa
Joaquin Alzola : > I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > [...] > > How is the best way to decode such reply from server? https://docs.python.org/3/library/stru

Re: Remote Rsponse Socket Connection

2016-03-11 Thread Andrew Berg
On 2016.03.11 07:17, Joaquin Alzola wrote: > HI Guys > > I received this from a socket connection. This is the received data: > > Adding more info --> the response is a mixture of hex numbers + ascii > > From python function --> data = s.recv(2048) > > b'

RE: Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
HI Guys I received this from a socket connection. This is the received data: Adding more info --> the response is a mixture of hex numbers + ascii >From python function --> data = s.recv(2048) b'\x01\x00\x00D\x00\x00\x01\x18\x00\x00\x00\x00p2E\xe1+\xe8xG\x00\x00\x01\x08@\x00\x00\

Remote Rsponse Socket Connection

2016-03-11 Thread Joaquin Alzola
HI Guys I received this from a socket connection. This is the received data: >From python function --> data = s.recv(2048) b'\x01\x00\x00D\x00\x00\x01\x18\x00\x00\x00\x00p2E\xe1+\xe8xG\x00\x00\x01\x08@\x00\x00\x0bmmm\x00\x00\x00\x01(@\x00\x00\x16mmm.xx.com\x00\x00\x00\x00\x01\x

Re: modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-12 Thread Matt Wheeler
On 11 February 2016 at 17:10, Ulli Horlacher wrote: > > Ulli Horlacher wrote: > As a hack, I modified the standard library module tarfile.py: > > root@diaspora:/usr/lib/python2.7# vv -d > --- ./.versions/tarfile.py~1~ 2015-06-22 21:59:27.0 +0200 > +++ tarfile.py 2016-02-11 18:01:50.185

Re: tarfile : read from a socket?

2016-02-12 Thread Ulli Horlacher
Lars Gustäbel wrote: > On Fri, Feb 12, 2016 at 09:35:40AM +0100, Antoon Pardon wrote: > > On 02/11/2016 06:27 PM, Lars Gustäbel wrote: > > > What about using an iterator? > > > > > > def myiter(tar): > > > for t in tar: > > > print "extracting", t.name > > > yield t > > > > > >

Re: tarfile : read from a socket?

2016-02-12 Thread Lars Gustäbel
On Fri, Feb 12, 2016 at 09:35:40AM +0100, Antoon Pardon wrote: > On 02/11/2016 06:27 PM, Lars Gustäbel wrote: > > What about using an iterator? > > > > def myiter(tar): > > for t in tar: > > print "extracting", t.name > > yield t > > > > sfo = sock.makefile('r') > > taro = tarfi

Re: tarfile : read from a socket?

2016-02-12 Thread Antoon Pardon
On 02/11/2016 06:27 PM, Lars Gustäbel wrote: > On Thu, Feb 11, 2016 at 04:41:43PM +, Ulli Horlacher wrote: >> sfo = sock.makefile('r') >> taro = tarfile.open(fileobj=sfo,mode='r|') >> taro.extractall(path=edir) > What about using an iterator? > > def myiter(tar): > for t in tar: >

Re: tarfile : read from a socket?

2016-02-11 Thread Random832
On Thu, Feb 11, 2016, at 11:41, Ulli Horlacher wrote: > When I use: > > for member in taro.getmembers(): > print('extracting "%s"' % member.name) > taro.extract(member) > > I get the error: > > File "/usr/lib/python2.7/tarfile.py", line 556, in seek > raise StreamError("seeki

Re: tarfile : read from a socket?

2016-02-11 Thread Lars Gustäbel
On Thu, Feb 11, 2016 at 04:41:43PM +, Ulli Horlacher wrote: > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) What about using an iterator? def myiter(tar): for t in tar: print "extracting", t.name yield t sfo = soc

Re: tarfile : read from a socket?

2016-02-11 Thread Peter Otten
Ulli Horlacher wrote: > Ulli Horlacher wrote: > >> With >> >> taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') >> >> I get no more error. > > Of course, this is the writing client. > > Now I have a small problem with the reading client. > > This code works so far: > > sfo

modifying a standard module? (was: Re: tarfile : read from a socket?)

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > This code works so far: > > sfo = sock.makefile('r') > taro = tarfile.open(fileobj=sfo,mode='r|') > taro.extractall(path=edir) > > But it does not writes anything to the terminal to inform the user. > > When I use: > > for member in taro.getmembers(): >

Re: tarfile : read from a socket?

2016-02-11 Thread MRAB
On 2016-02-11 16:41, Ulli Horlacher wrote: Ulli Horlacher wrote: With taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') I get no more error. Of course, this is the writing client. Now I have a small problem with the reading client. This code works so far: sfo = sock.ma

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > With > > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w|') > > I get no more error. Of course, this is the writing client. Now I have a small problem with the reading client. This code works so far: sfo = sock.makefile('r') taro = tarfile.open(fil

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Chris Angelico wrote: > Sounds like tarfile needs a seekable file. How big is this file you're > reading? No limits. It can be many TBs... The use case is: http://fex.rus.uni-stuttgart.de:8080/ -- Ullrich Horlacher Server und Virtualisierung Rechenzentrum IZUS/TIK E-Mai

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Ulli Horlacher wrote: > I have: > > sock = socket.create_connection((server,port)) > bs = kB64 > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w') > > > > Traceback (most recent call last): > (...) > File "./fexit.py", line 1838, in sex_send > taro = tarf

Re: tarfile : read from a socket?

2016-02-11 Thread Chris Angelico
On Thu, Feb 11, 2016 at 11:53 PM, Ulli Horlacher wrote: > I have: > > sock = socket.create_connection((server,port)) > bs = kB64 > taro = tarfile.open(fileobj=sock.makefile('w',kB64),mode='w') > > > > Traceback (most recent call last): > (...) > File "./fexit.py", line 1838, in sex_send

Re: tarfile : read from a socket?

2016-02-11 Thread MRAB
On 2016-02-11 12:53, Ulli Horlacher wrote: Antoon Pardon wrote: > (How) can I read a tar file from a (tcp) socket? > I do not have a pathname but a socket object from socket.create_connection # First you construct a file object with makefile. fo = socket.makefile() # Then you u

Re: tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
Antoon Pardon wrote: > > (How) can I read a tar file from a (tcp) socket? > > I do not have a pathname but a socket object from socket.create_connection > > # First you construct a file object with makefile. > > fo = socket.makefile() > > # Then you use the file

Re: tarfile : read from a socket?

2016-02-11 Thread Antoon Pardon
On 02/11/2016 09:31 AM, Ulli Horlacher wrote: > https://docs.python.org/2/library/tarfile.html says: > > tarfile.open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs) > > Return a TarFile object for the pathname name. > > > (How) can I read a ta

Re: tarfile : read from a socket?

2016-02-11 Thread INADA Naoki
Have you tried socket.makefile() method? -- https://mail.python.org/mailman/listinfo/python-list

tarfile : read from a socket?

2016-02-11 Thread Ulli Horlacher
https://docs.python.org/2/library/tarfile.html says: tarfile.open(name=None, mode='r', fileobj=None, bufsize=10240, **kwargs) Return a TarFile object for the pathname name. (How) can I read a tar file from a (tcp) socket? I do not have a pathname but a socket o

asyncio for UNIX socket

2015-12-16 Thread Pavlos Parissis
Hi, I am trying to write UNIX socket client which sends 1 cmd and saves the received data to a file. Based on what I found on documentation I came up with:: import asyncio class UnixProtocol(asyncio.Protocol): def __init__(self, loop): self.cmd = 'show stat\n' self.l

Re: how to get python socket to use a specific interface

2015-10-28 Thread Cameron Simpson
On 28Oct2015 10:41, Robin Becker wrote: binding to the local IP seems to be a windows only thing. No, it is a pretty standard BSD socket layer thing. (Windows got its original TCP stack from there too). I just tested a Linux RHEL6 host binding to a specific address just now using telnet

Re: how to get python socket to use a specific interface

2015-10-28 Thread Robin Becker
.. binding to the local IP seems to be a windows only thing. No, it is a pretty standard BSD socket layer thing. (Windows got its original TCP stack from there too). I just tested a Linux RHEL6 host binding to a specific address just now using telnet: /usr/bin/telnet -b x.x.x.193

Re: how to get python socket to use a specific interface

2015-10-27 Thread Cameron Simpson
/questions/335607/how-do-i-make-an-outgoing-socket-to-a-specific-network-interface http://stackoverflow.com/questions/8437726/can-python-select-what-network-adapter-when-opening-a-socket binding to the local IP seems to be a windows only thing. No, it is a pretty standard BSD socket layer thing. (W

Re: how to get python socket to use a specific interface

2015-10-27 Thread Robin Becker
correct IP address should normally be sufficient. The system you're talking to won't know anything about the device, only the address. Try skipping the device binding step. According to the stackoverflow articles here http://stackoverflow.com/questions/335607/how-do-i-make-an-outgoing-s

Re: how to get python socket to use a specific interface

2015-10-26 Thread Cameron Simpson
On 26Oct2015 12:33, Robin Becker wrote: . device? -- Robin Becker Using eth0:0 is normally a method to setup eth0 to respond to a 2nd IPV4/IPV6 address. Have you done the ifconfig steps to enable that? If its been done, you will see it's 2nd address in an ifconfig query. Man pa

Re: how to get python socket to use a specific interface

2015-10-26 Thread Robin Becker
ginal email; when I try to execute the commands to bind to that device I get an error eg # ~rptlab/tmp/proxy/bin/python Python 2.7.5 (default, Aug 20 2013, 15:27:38) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more inform

Re: how to get python socket to use a specific interface

2015-10-25 Thread Gene Heskett
proxy and hacked the connection code so it looked > like this > > > proxy.py > .... > > > from socket import socket, SOL_SOCKET > > ... > > import os > > BIND_ADDRESS = os.environ.get('PYMIPROXY_BIND_ADDRESS',None) > > BIND_DEVICE = os.env

how to get python socket to use a specific interface

2015-10-23 Thread Robin Becker
from socket import socket, SOL_SOCKET ... import os BIND_ADDRESS = os.environ.get('PYMIPROXY_BIND_ADDRESS',None) BIND_DEVICE = os.environ.get('PYMIPROXY_BIND_DEVICE',None) . # Connect to destination sock = self._proxy_sock = socket() sock.

Re: Lightwight socket IO wrapper

2015-09-22 Thread Gregory Ewing
Random832 wrote: Isn't this technically the same problem as pressing ctrl-d at a terminal - it's not _really_ the end of the input (you can continue reading after), but it sends the program something it will interpret as such? Yes. There's no concept of "closing the connection" with UDP, becau

Re: Lightwight socket IO wrapper

2015-09-22 Thread Random832
On Tue, Sep 22, 2015, at 15:45, James Harris wrote: > "Dennis Lee Bieber" wrote in message > news:mailman.12.1442794762.28679.python-l...@python.org... > > On Sun, 20 Sep 2015 23:36:30 +0100, "James Harris" > > declaimed the following: > >>Receiving no bytes is taken as indicating the end of the

Re: Lightwight socket IO wrapper

2015-09-22 Thread James Harris
"Marko Rauhamaa" wrote in message news:8737y6cgp6@elektro.pacujo.net... "James Harris" : I agree with what you say. A zero-length UDP datagram should be possible and not indicate end of input but is that guaranteed and portable? The zero-length payload size shouldn't be an issue, but UDP

Re: Lightwight socket IO wrapper

2015-09-22 Thread Marko Rauhamaa
"James Harris" : > I agree with what you say. A zero-length UDP datagram should be > possible and not indicate end of input but is that guaranteed and > portable? The zero-length payload size shouldn't be an issue, but UDP doesn't make any guarantees about delivering the message. Your UDP applica

Re: Lightwight socket IO wrapper

2015-09-22 Thread James Harris
of what was documented, of course. I agree with what you say. A zero-length UDP datagram should be possible and not indicate end of input but is that guaranteed and portable? (Rhetorical.) It seems not. Even the Linux man page for recv says: "If no messages are available at the s

Re: Lightwight socket IO wrapper

2015-09-22 Thread James Harris
f a big message is sent successfully.) Looking in the wrong documentation You probably should be looking at the UDP RFC. Or maybe just http://www.diffen.com/difference/TCP_vs_UDP """ Packets are sent individually and are checked for integrity only if they arrive. Packets have definit

Re: Lightwight socket IO wrapper

2015-09-22 Thread Jorgen Grahn
>>> encoding. >>> >>> Not sure what you mean there. Unless you can absolutely guarantee that >>> you didn't read too much, or can absolutely guarantee that your >>> buffering function will be the ONLY way anything reads from the >>> socket,

Re: Lightwight socket IO wrapper

2015-09-22 Thread Jorgen Grahn
On Mon, 2015-09-21, Cameron Simpson wrote: > On 21Sep2015 10:34, Chris Angelico wrote: >>If you're going to add sequencing and acknowledgements to UDP, >>wouldn't it be easier to use TCP and simply prefix every message with >>a two-byte length? > > Frankly, often yes. That's what I do. (different

Re: Lightwight socket IO wrapper

2015-09-21 Thread Cameron Simpson
can read a full buffer even if you have a variable-length length encoding. Not sure what you mean there. Unless you can absolutely guarantee that you didn't read too much, or can absolutely guarantee that your buffering function will be the ONLY way anything reads from the socket, buffering is a

Re: Lightwight socket IO wrapper

2015-09-21 Thread MRAB
available? Or does the implementation have to look into sys.platform? >>> import socket >>> 'TCP_CORK' in dir(socket) True On which platform was this done? Python3 on Fedora 21. Python2 on RHEL4. Sorry, don't have non-Linux machines to try. How to auto

Re: Lightwight socket IO wrapper

2015-09-21 Thread Jorgen Grahn
_vs_UDP > > """ > Packets are sent individually and are checked for integrity only if they > arrive. Packets have definite boundaries which are honored upon receipt, > meaning a read operation at the receiver socket will yield an entire > message as it was originally sen

Re: Lightwight socket IO wrapper

2015-09-21 Thread Chris Angelico
there. Unless you can absolutely guarantee that >> you didn't read too much, or can absolutely guarantee that your >> buffering function will be the ONLY way anything reads from the >> socket, buffering is a problem. > > Only one reader can read a socket safely at any give

Re: Lightwight socket IO wrapper

2015-09-21 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Sep 21, 2015 at 6:38 PM, Marko Rauhamaa wrote: >> Only one reader can read a socket safely at any given time so mutual >> exclusion is needed. >> >> If you read "too much," the excess can be put in the application's read &

Re: Lightwight socket IO wrapper

2015-09-21 Thread Marko Rauhamaa
vailable are both option constants also not >>> available? Or does the implementation have to look into sys.platform? >> >>>>> import socket >>>>> 'TCP_CORK' in dir(socket) >>True > > On which platform was this done? Pyt

Re: Lightwight socket IO wrapper

2015-09-21 Thread Marko Rauhamaa
Marko Rauhamaa : > Chris Angelico : > >> On Mon, Sep 21, 2015 at 6:38 PM, Marko Rauhamaa wrote: >>> Only one reader can read a socket safely at any given time so mutual >>> exclusion is needed. >>> >>> If you read "too much," the excess c

  1   2   3   4   5   6   7   8   9   10   >