Client with select.select()

A[r]TA arta at NOSPAMx-stream.nl
Mon Jun 12 06:56:50 EDT 2000


Hi,

What's wrong?
I have some simple server programmed for experiments. You can chat with it.
blabla.
But with the code below, I want to connect with it. In the beginning it
prints a welcome message.
Or, it's meant to do. But it only prints the first line from the
welcome-message and not the
following. What am I doing wrong? Because in the logfile from my server,
there's  a line
in which stands that a login-connection has been made. So that's good.
But what am I doing wrong? I want the whole message printed, not the first
line.

Excuse me for my English, blame my teacher :)

A[r]TA

--
-Life can kick your ass, but all you got to do is stand up and move on...



----------------------------------------------------------------------------
--------------
----------------------------------------------------------------------------
--------------



from socket import *
from select import *

s = socket(AF_INET, SOCK_STREAM)
s.connect('127.0.0.1', 23)
text = ''

while 1:
    q = [s.fileno()]
    rd, wr, er = select(q, q, [], None)

    for n in rd:
        if n == s.fileno():
            print rd, wr, er, q
            text = s.makefile().readline()
            print text

    for n in wr:
        if n == s.fileno():
            g = 'password' +chr(13)+ '\n'
            s.send(g)






More information about the Python-list mailing list