Getting one character at a time from sockets

penman pen_man at my-deja.com
Tue Feb 6 23:24:46 EST 2001


In article <95qg45$5b0$0 at 216.39.151.169>,
  Donn Cave <donn at oz.net> wrote:
> Quoth penman <pen_man at my-deja.com>:
> | Using ordinary TCP/IP sockets with the socket module in Python, I
need
> | to get a single character at a time from the client; something
> | like "talk" in unix. How could I do that? (should be platform
> | independent if possible)
> |
> | recv(1) didn't work. It waited till the carriage return came in.
(non-
> | blocking didn't work either)
>
> Don't mess around with non-blocking.  Even recv(8000) will return
> more or less immediately if you send any data at all, so it seems
> kind of likely you're sending no data until the CR.  Substitute a
> test client that has its data built in, and just send('i') to the
> server.  I bet recv() will get it right away, Nagel algorithms
> notwithstanding.
>
> 	Donn Cave, donn at oz.net
>

Thank you, Donn. But the problem is that I have to use ordinary telnet
clients, such as CRT, Netterm, so let the users access to the server
without any specialy programs.

I wonder why nobody ever had the need to recv 1 character "unbuffered"
in Python.


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list