Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61624 > unrolled thread
| Started by | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| First post | 2013-12-11 15:08 -0800 |
| Last post | 2013-12-13 00:43 +0100 |
| Articles | 20 on this page of 46 — 13 participants |
Back to article view | Back to comp.lang.python
[newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-11 15:08 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-11 15:20 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 00:28 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 13:23 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 19:23 -0800
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 19:32 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 03:03 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 03:56 -0800
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-13 08:35 +0000
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-13 04:20 -0800
Re: [newbie] trying socket as a replacement for nc rusi <rustompmody@gmail.com> - 2013-12-13 09:04 -0800
Re: [newbie] trying socket as a replacement for nc rusi <rustompmody@gmail.com> - 2013-12-13 09:09 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-14 05:11 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-14 05:14 -0800
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-14 13:29 +0000
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-16 01:40 -0800
Re: [newbie] trying socket as a replacement for nc Ervin Hegedüs <airween@gmail.com> - 2013-12-16 11:04 +0100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-12 14:16 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-13 01:23 +1100
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-12 13:27 -0800
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:06 +0000
Re: [newbie] trying socket as a replacement for nc Dan Stromberg <drsalists@gmail.com> - 2013-12-14 17:24 -0800
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-15 15:15 +0000
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-15 10:51 -0500
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 03:04 +1100
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-15 12:44 -0500
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-15 22:42 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 09:48 +1100
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-13 08:58 +1100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:10 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-14 03:19 +1100
Re: [newbie] trying socket as a replacement for nc Grant Edwards <invalid@invalid.invalid> - 2013-12-13 16:57 +0000
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-14 04:05 +1100
Re: [newbie] trying socket as a replacement for nc 88888 Dihedral <dihedral88888@gmail.com> - 2013-12-16 04:38 -0800
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-16 23:59 +1100
Re: [newbie] trying socket as a replacement for nc Roy Smith <roy@panix.com> - 2013-12-16 09:03 -0500
Re: [newbie] trying socket as a replacement for nc 88888 Dihedral <dihedral88888@gmail.com> - 2013-12-18 23:20 -0800
Re: [newbie] trying socket as a replacement for nc Dave Angel <davea@davea.name> - 2013-12-12 19:52 -0500
Re: [newbie] trying socket as a replacement for nc Conor Hughes <conorh@conorh.net> - 2013-12-11 15:38 -0800
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 00:08 -0800
Re: [newbie] trying socket as a replacement for nc Chris Angelico <rosuav@gmail.com> - 2013-12-12 19:21 +1100
Re: [newbie] trying socket as a replacement for nc Jean Dubois <jeandubois314@gmail.com> - 2013-12-12 01:21 -0800
Re: [newbie] trying socket as a replacement for nc Alister <alister.ware@ntlworld.com> - 2013-12-12 14:05 +0000
Re: [newbie] trying socket as a replacement for nc Alister <alister.ware@ntlworld.com> - 2013-12-12 14:05 +0000
Re: [newbie] trying socket as a replacement for nc Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-12 14:34 +0000
Re: [newbie] trying socket as a replacement for nc Christian Gollwitzer <auriocus@gmx.de> - 2013-12-13 00:43 +0100
Page 1 of 3 [1] 2 3 Next page →
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-11 15:08 -0800 |
| Subject | [newbie] trying socket as a replacement for nc |
| Message-ID | <efae1b3c-c9c5-4ef4-8e94-7fbe8716ab53@googlegroups.com> |
I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system.
e.g. entering nc 10.128.59.63 7000
allows me to enter e.g.
*IDN?
after which I get an identification string of the measurement instrument back.
I thought I could accomplish the same using the python module "socket"
and tried out the sample program below which doesn't work however:
#!/usr/bin/env python
"""
A simple echo client
"""
import socket
host = '10.128.59.63'
port = 7000
size = 10
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send('*IDN?')
data = s.recv(size)
s.close()
print 'Received:', data
Can anyone here tell me how to do it properly?
thanks in advance
jean
[toc] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-12-11 15:20 -0800 |
| Message-ID | <mailman.3939.1386804043.18130.python-list@python.org> |
| In reply to | #61624 |
[Multipart message — attachments visible in raw view] — view raw
On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandubois314@gmail.com>wrote: > I have an ethernet-rs232 adapter which allows me to connect to a > measurement instrument by means of netcat on a linux system. > e.g. entering nc 10.128.59.63 7000 > allows me to enter e.g. > *IDN? > after which I get an identification string of the measurement instrument > back. > I thought I could accomplish the same using the python module "socket" > and tried out the sample program below which doesn't work however: > Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability. The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session). But writing your code assuming it will never happen is a bad idea. For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page. HTH
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-12 00:28 -0800 |
| Message-ID | <d05fddc8-ad6c-488b-b0d2-ad5257b2aac8@googlegroups.com> |
| In reply to | #61626 |
On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: > On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote: > > I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system. > > > e.g. entering nc 10.128.59.63 7000 > > allows me to enter e.g. > > *IDN? > > after which I get an identification string of the measurement instrument back. > > I thought I could accomplish the same using the python module "socket" > > and tried out the sample program below which doesn't work however: > > > > Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability. > > > The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session). But writing your code assuming it will never happen is a bad idea. > > > > For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page. > > > > HTH Dear Dan, Could you copy paste here the code for your function I have to add to my "program"? thanks in advance jean
[toc] | [prev] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-12-12 13:23 -0800 |
| Message-ID | <mailman.4026.1386883409.18130.python-list@python.org> |
| In reply to | #61681 |
On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote:
> On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote:
>> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote:
>>
>> I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system.
>>
>>
>> e.g. entering nc 10.128.59.63 7000
>>
>> allows me to enter e.g.
>>
>> *IDN?
>>
>> after which I get an identification string of the measurement instrument back.
>>
>> I thought I could accomplish the same using the python module "socket"
>>
>> and tried out the sample program below which doesn't work however:
>>
>>
>>
>> Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability.
>>
>>
>> The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session). But writing your code assuming it will never happen is a bad idea.
>>
>>
>>
>> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page.
>>
>>
>>
>> HTH
>
> Dear Dan,
> Could you copy paste here the code for your function I have to add to my "program"?
This is untested, but it should be something like the following:
#!/usr/bin/env python
"""
A simple echo client
"""
import socket as socket_mod
import bufsock as bufsock_mod
host = '10.128.59.63'
port = 7000
size = 10
socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((host,port))
bufsock = bufsock_mod.bufsock(socket)
bufsock.send('*IDN?')
data = bufsock.recv(size)
bufsock.close()
print 'Received:', data
You might look over
http://stackoverflow.com/questions/19918307/retrieve-file-information-located-on-a-different-application-server-using-python/19918706#19918706
for a more complete example.
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-12 19:23 -0800 |
| Message-ID | <693052e5-a884-460a-8dc1-9a13b6d829aa@googlegroups.com> |
| In reply to | #61757 |
Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg:
> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote:
>
> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote:
>
> >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote:
>
> >>
>
> >> I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system.
>
> >>
>
> >>
>
> >> e.g. entering nc 10.128.59.63 7000
>
> >>
>
> >> allows me to enter e.g.
>
> >>
>
> >> *IDN?
>
> >>
>
> >> after which I get an identification string of the measurement instrument back.
>
> >>
>
> >> I thought I could accomplish the same using the python module "socket"
>
> >>
>
> >> and tried out the sample program below which doesn't work however:
>
> >>
>
> >>
>
> >>
>
> >> Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability.
>
> >>
>
> >>
>
> >> The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session). But writing your code assuming it will never happen is a bad idea.
>
> >>
>
> >>
>
> >>
>
> >> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page.
>
> >>
>
> >>
>
> >>
>
> >> HTH
>
> >
>
> > Dear Dan,
>
> > Could you copy paste here the code for your function I have to add to my "program"?
>
>
>
> This is untested, but it should be something like the following:
>
>
>
> #!/usr/bin/env python
>
>
>
> """
>
> A simple echo client
>
> """
>
> import socket as socket_mod
>
> import bufsock as bufsock_mod
>
> host = '10.128.59.63'
>
> port = 7000
>
> size = 10
>
> socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM)
>
> socket.connect((host,port))
>
> bufsock = bufsock_mod.bufsock(socket)
>
> bufsock.send('*IDN?')
>
> data = bufsock.recv(size)
>
> bufsock.close()
>
> print 'Received:', data
>
>
>
> You might look over
>
> http://stackoverflow.com/questions/19918307/retrieve-file-information-located-on-a-different-application-server-using-python/19918706#19918706
>
> for a more complete example.
Thank you very much for the example, the only trouble I'm having now is installing the bufsock module:
wget http://dcs.nac.uci.edu/~strombrg/bufsock.tar.gz
results in The requested URL /~strombrg/bufsock.tar.gz was not found on this server.
Could you supply me the necessary installation instructions?
kind regards,
jean
p.s. I'm using Linux/Kubuntu 11.04
[toc] | [prev] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-12-12 19:32 -0800 |
| Message-ID | <mailman.4045.1386905558.18130.python-list@python.org> |
| In reply to | #61786 |
On Thu, Dec 12, 2013 at 7:23 PM, Jean Dubois <jeandubois314@gmail.com> wrote: > Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg: >> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote: >> >> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: >> >> >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote: >> >> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page. > Thank you very much for the example, the only trouble I'm having now is installing the bufsock module: > wget http://dcs.nac.uci.edu/~strombrg/bufsock.tar.gz > results in The requested URL /~strombrg/bufsock.tar.gz was not found on this server. > Could you supply me the necessary installation instructions? That's an old link. It's now at http://stromberg.dnsalias.org/~strombrg/bufsock.html HTH
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-13 03:03 -0800 |
| Message-ID | <cf056540-9777-4f3b-a596-69b7751a4ce4@googlegroups.com> |
| In reply to | #61787 |
Op vrijdag 13 december 2013 04:32:30 UTC+1 schreef Dan Stromberg: > On Thu, Dec 12, 2013 at 7:23 PM, Jean Dubois <jeandubois314@gmail.com> wrote: > > > Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg: > > >> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote: > > >> > > >> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: > > >> > > >> >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote: > > > > >> >> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page. > > > > > Thank you very much for the example, the only trouble I'm having now is installing the bufsock module: > > > wget http://dcs.nac.uci.edu/~strombrg/bufsock.tar.gz > > > results in The requested URL /~strombrg/bufsock.tar.gz was not found on this server. > > > Could you supply me the necessary installation instructions? > > > > That's an old link. It's now at > > http://stromberg.dnsalias.org/~strombrg/bufsock.html > > > > HTH I surfed to the new download-link (http://stromberg.dnsalias.org/svn/bufsock/) but I don't see any instructions how to download or install bufsock.py, I see it has something to do with svn which I don't know how to handle. Could you help me with that too? thanks in advance jean http://stromberg.dnsalias.org/svn/bufsock/
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-13 03:56 -0800 |
| Message-ID | <b60026dc-3599-4806-9ec9-89a26ea513b2@googlegroups.com> |
| In reply to | #61787 |
Op vrijdag 13 december 2013 04:32:30 UTC+1 schreef Dan Stromberg: > On Thu, Dec 12, 2013 at 7:23 PM, Jean Dubois <jeandubois314@gmail.com> wrote: > > > Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg: > > >> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote: > > >> > > >> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote: > > >> > > >> >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote: > > > > >> >> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page. > > > > > Thank you very much for the example, the only trouble I'm having now is installing the bufsock module: > > > wget http://dcs.nac.uci.edu/~strombrg/bufsock.tar.gz > > > results in The requested URL /~strombrg/bufsock.tar.gz was not found on this server. > > > Could you supply me the necessary installation instructions? > > > > That's an old link. It's now at > > http://stromberg.dnsalias.org/~strombrg/bufsock.html > > > > HTH I surfed to the new download-link (http://stromberg.dnsalias.org/svn/bufsock/) but I don't see any instructions how to download or install bufsock.py, I see it has something to do with svn which I don't know how to handle. Could you help me with that too? thanks in advance jean http://stromberg.dnsalias.org/svn/bufsock/
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-13 08:35 +0000 |
| Message-ID | <mailman.4051.1386923741.18130.python-list@python.org> |
| In reply to | #61786 |
On 13/12/2013 03:23, Jean Dubois wrote: > > kind regards, > jean > p.s. I'm using Linux/Kubuntu 11.04 > Would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing that accompanied the above, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-13 04:20 -0800 |
| Message-ID | <b4014175-e032-409f-857a-93b688efae4b@googlegroups.com> |
| In reply to | #61800 |
Op vrijdag 13 december 2013 09:35:18 UTC+1 schreef Mark Lawrence: > Would you please read and action this > https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the > double line spacing that accompanied the above, thanks. > > -- > > Mark Lawrence Dear Mark, I'm sorry for the inconvenience my postings may have caused. I now have followed the instructions on the link you mentioned and installed the plugin en python-script. hope it worked (I saw the text light up yellow when pressing the edit-key a second time). A small suggestion from a newbie: it would perhaps be possible to make the script check itself whether pyhon2 or python3 should be used? thanks for having patience with me kind regards, jean
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-12-13 09:04 -0800 |
| Message-ID | <0066006f-6be6-40d0-b147-400bd81bfae7@googlegroups.com> |
| In reply to | #61817 |
On Friday, December 13, 2013 5:50:03 PM UTC+5:30, Jean Dubois wrote: > Op vrijdag 13 december 2013 09:35:18 UTC+1 schreef Mark Lawrence: > > Would you please read and action this > > https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the > > double line spacing that accompanied the above, thanks. > > -- > > Mark Lawrence > Dear Mark, > I'm sorry for the inconvenience my postings may have caused. I now have > followed > the instructions on the link you mentioned and installed the plugin en > python-script. Thanks for cooperating > hope it worked (I saw the text light up yellow when pressing the edit-key a second time). A small suggestion from a newbie: it would perhaps be possible > to make the script check itself whether pyhon2 or python3 should be used? Yes... Half way The double-spacing problem is cured However the long-lines remain (see your "hope it worked..." above) Did you click the edit button both before and after your typing? The 'before' should remove the double-spaced (old >...) lines The 'after' should even out the right margins of what you've just typed > thanks for having patience with me Yes and you too please bear with us as we iron out this little irritant niggle
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-12-13 09:09 -0800 |
| Message-ID | <d59a2940-5818-4c4c-8103-12a918713bfb@googlegroups.com> |
| In reply to | #61817 |
On Friday, December 13, 2013 5:50:03 PM UTC+5:30, Jean Dubois wrote: > to make the script check itself whether pyhon2 or python3 should be used? As far as I know both (2 and 3) worked Do you have some reason to suspect one works and other not?
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-14 05:11 -0800 |
| Message-ID | <403bad3a-5d8b-4814-87f0-84b18be842cf@googlegroups.com> |
| In reply to | #61848 |
Op vrijdag 13 december 2013 18:09:50 UTC+1 schreef rusi: > On Friday, December 13, 2013 5:50:03 PM UTC+5:30, Jean Dubois wrote: > > to make the script check itself whether pyhon2 or python3 should be used? > As far as I know both (2 and 3) worked > Do you have some reason to suspect one works and other not? The reason I suggested this is that the script has #!/usr/bin/env python3 as the first line. When you have python2 installed and not python3 a newbie will probably not understand why it doesn't work. kind regards, jean
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-14 05:14 -0800 |
| Message-ID | <6ac262ef-507e-471c-ba1f-8ef954b93972@googlegroups.com> |
| In reply to | #61800 |
Op vrijdag 13 december 2013 09:35:18 UTC+1 schreef Mark Lawrence: > On 13/12/2013 03:23, Jean Dubois wrote: > > > > kind regards, > > jean > > p.s. I'm using Linux/Kubuntu 11.04 > > > Would you please read and action this > https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the > double line spacing that accompanied the above, thanks. I think I got it right this time. Thanks for helping me through it. kind regards, jean
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-14 13:29 +0000 |
| Message-ID | <mailman.4113.1387027808.18130.python-list@python.org> |
| In reply to | #61893 |
On 14/12/2013 13:14, Jean Dubois wrote: > Op vrijdag 13 december 2013 09:35:18 UTC+1 schreef Mark Lawrence: >> On 13/12/2013 03:23, Jean Dubois wrote: >>> >>> kind regards, >>> jean >>> p.s. I'm using Linux/Kubuntu 11.04 >>> >> Would you please read and action this >> https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the >> double line spacing that accompanied the above, thanks. > I think I got it right this time. Thanks for helping me through it. > > kind regards, > jean > Yep, I've seen a couple of your posts that are just fine. Thanks for taking these steps, I greatly appreciate your efforts. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
[toc] | [prev] | [next] | [standalone]
| From | Jean Dubois <jeandubois314@gmail.com> |
|---|---|
| Date | 2013-12-16 01:40 -0800 |
| Message-ID | <341e261d-ea7b-4d5a-ab41-9c0d44352d2b@googlegroups.com> |
| In reply to | #61757 |
Op donderdag 12 december 2013 22:23:22 UTC+1 schreef Dan Stromberg:
> On Thu, Dec 12, 2013 at 12:28 AM, Jean Dubois <jeandubois314@gmail.com> wrote:
> > On Thursday, December 12, 2013 12:20:36 AM UTC+1, Dan Stromberg wrote:
> >> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandu...@gmail.com> wrote:
> >>
> >> I have an ethernet-rs232 adapter which allows me to connect to a measurement instrument by means of netcat on a linux system.
> >>
> >>
> >> e.g. entering nc 10.128.59.63 7000
> >>
> >> allows me to enter e.g.
> >>
> >> *IDN?
> >>
> >> after which I get an identification string of the measurement instrument back.
> >>
> >> I thought I could accomplish the same using the python module "socket"
> >>
> >> and tried out the sample program below which doesn't work however:
> >>
> >>
> >>
> >> Sockets reserve the right to split one socket.send() into multiple socket.recv()'s on the other end of the communication, or to aggregate multiple socket.send()'s into a single socket.recv() - pretty much any way the relevant IP stacks and communications equipment feel like for the sake of performance or reliability.
> >>
> >>
> >> The confusing thing about this is, it won't be done on every transmission - in fact, it'll probably happen rather seldom unless you're on a heavy loaded network or have some MTU issues (see Path MTU Discovery, and bear in mind that paths can change during a TCP session). But writing your code assuming it will never happen is a bad idea.
> >>
> >>
> >>
> >> For this reason, I wrote http://stromberg.dnsalias.org/~strombrg/bufsock.html , which abstracts away these complications, and actually makes things pretty simple. There are examples on the web page.
> >>
> >>
> >>
> >> HTH
> >
> > Dear Dan,
> > Could you copy paste here the code for your function I have to add to my "program"?
> This is untested, but it should be something like the following:
> #!/usr/bin/env python
> """
> A simple echo client
> """
> import socket as socket_mod
> import bufsock as bufsock_mod
> host = '10.128.59.63'
> port = 7000
> size = 10
> socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM)
> socket.connect((host,port))
> bufsock = bufsock_mod.bufsock(socket)
> bufsock.send('*IDN?')
> data = bufsock.recv(size)
> bufsock.close()
> print 'Received:', data
> You might look over
> http://stackoverflow.com/questions/19918307/retrieve-file-information-located-on-a-different-application-server-using-python/19918706#19918706
> for a more complete example.
So this is what I did:
1. svn checkout http://stromberg.dnsalias.org/svn/bufsock/
2. cd ~/bufsock/trunk
3. I made this test-file "buftest.py" with the following contents:
#!/usr/bin/env python
"""
A simple echo client
"""
import socket as socket_mod
import bufsock as bufsock_mod
host = '10.128.59.63'
port = 7000
size = 10
socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.connect((host,port))
bufsock = bufsock_mod.bufsock(socket)
bufsock.send('*IDN?')
data = bufsock.recv(size)
bufsock.close()
print 'Received:', data
4. chmod +x buftest.py
5. ./buftest.py
6. This results in the following error message:
Traceback (most recent call last):
File "./buftest.py", line 11, in <module>
socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM)
NameError: name 'socket' is not defined
Probably there is still something wrong, can anyone here help me further?
kind regards,
jean
[toc] | [prev] | [next] | [standalone]
| From | Ervin Hegedüs <airween@gmail.com> |
|---|---|
| Date | 2013-12-16 11:04 +0100 |
| Message-ID | <mailman.4196.1387188274.18130.python-list@python.org> |
| In reply to | #62032 |
hello, > #!/usr/bin/env python > > """ > A simple echo client > """ > import socket as socket_mod > import bufsock as bufsock_mod [...] > Traceback (most recent call last): > File "./buftest.py", line 11, in <module> > socket = socket_mod.socket(socket.AF_INET, socket.SOCK_STREAM) > NameError: name 'socket' is not defined you should replace the socket.AF_INET to socket_mod.AF_INET, and socket.SOCK_STREAM to socket_mod.SOCK_STREAM, if you've imported socket modul as socket_mod. But this is just an idea... :) a.
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2013-12-12 14:16 +0000 |
| Message-ID | <l8cggd$fl9$1@reader1.panix.com> |
| In reply to | #61626 |
On 2013-12-11, Dan Stromberg <drsalists@gmail.com> wrote:
> On Wed, Dec 11, 2013 at 3:08 PM, Jean Dubois <jeandubois314@gmail.com>wrote:
>
>> I have an ethernet-rs232 adapter which allows me to connect to a
>> measurement instrument by means of netcat on a linux system.
>> e.g. entering nc 10.128.59.63 7000
>> allows me to enter e.g.
>> *IDN?
>> after which I get an identification string of the measurement instrument
>> back.
>> I thought I could accomplish the same using the python module "socket"
>> and tried out the sample program below which doesn't work however:
>>
>
> Sockets reserve the right to split one socket.send() into multiple
> socket.recv()'s on the other end of the communication, or to aggregate
> multiple socket.send()'s into a single socket.recv() - pretty much any way
> the relevant IP stacks and communications equipment feel like for the sake
> of performance or reliability.
Just to be pedantic: _TCP_ sockets reserver that right. UDP sockets
do not, and do in fact guarantee that each message is discrete. [It
appears that the OP is undoubtedly using TCP sockets.]
> The confusing thing about this is, it won't be done on every
> transmission - in fact, it'll probably happen rather seldom unless
> you're on a heavy loaded network or have some MTU issues (see Path
> MTU Discovery, and bear in mind that paths can change during a TCP
> session). But writing your code assuming it will never happen is a
> bad idea.
And it _will_ fail someday in some odd circumstance when, for example,
some customer is be using it via a dial-up PPP connection, or there is
a satellite link in the path, or there's a flakey router somewhere,
or...
--
Grant Edwards grant.b.edwards Yow! Those people look
at exactly like Donnie and
gmail.com Marie Osmond!!
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-12-13 01:23 +1100 |
| Message-ID | <mailman.3992.1386858218.18130.python-list@python.org> |
| In reply to | #61715 |
On Fri, Dec 13, 2013 at 1:16 AM, Grant Edwards <invalid@invalid.invalid> wrote: > And it _will_ fail someday in some odd circumstance when, for example, > some customer is be using it via a dial-up PPP connection, or there is > a satellite link in the path, or there's a flakey router somewhere, > or... Or you write, write, write in quick succession. Nagle's Algorithm means that if the first one hasn't yet been acknowledged, the second one will be delayed, which means it'll probably be combined with the third and sent when the first one's ACK comes through. Stream sockets guarantee a stream of bytes; datagram sockets guarantee datagrams. Weird how that goes, isn't it? ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-12-12 13:27 -0800 |
| Message-ID | <mailman.4027.1386883640.18130.python-list@python.org> |
| In reply to | #61715 |
On Thu, Dec 12, 2013 at 6:16 AM, Grant Edwards <invalid@invalid.invalid> wrote: >> Sockets reserve the right to split one socket.send() into multiple >> socket.recv()'s on the other end of the communication, or to aggregate >> multiple socket.send()'s into a single socket.recv() - pretty much any way >> the relevant IP stacks and communications equipment feel like for the sake >> of performance or reliability. > > Just to be pedantic: _TCP_ sockets reserver that right. UDP sockets > do not, and do in fact guarantee that each message is discrete. [It > appears that the OP is undoubtedly using TCP sockets.] I haven't done a lot of UDP, but are you pretty sure UDP can't at least fragment large packets? What's a router or switch to do if the Path MTU isn't large enough for an original packet? http://www.gamedev.net/topic/343577-fragmented-udp-packets/
[toc] | [prev] | [next] | [standalone]
Page 1 of 3 [1] 2 3 Next page →
Back to top | Article view | comp.lang.python
csiph-web