Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Conor Hughes Newsgroups: comp.lang.python Subject: Re: [newbie] trying socket as a replacement for nc Date: Wed, 11 Dec 2013 15:38:12 -0800 Organization: A noiseless patient Spider Lines: 20 Message-ID: <87zjo7dkm3.fsf@conorh.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="6426ae6f89819349614b2c21d8df16e8"; logging-data="22875"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/M3m6vAgJlmsAZxj/zltJn" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:49GvF+pE46SKHRnqYxv+s7ypVEQ= sha1:joO6CDh/ZtaXBEuVIvOOAZ0cVxY= Xref: csiph.com comp.lang.python:61628 Jean Dubois writes: > 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: In what way does it not work? Do you not get any data? Do you get the wrong data? Does your program block at a point which you do not understand? Probably more to the point, are you sure you are sending exactly the same data as you did with netcat? netcat running with stdin a terminal sends data line-by-line, and includes the newline in the data that it sends. You didn't send a newline in your example.