Another Socket in Python
sadams123 at optushome.com.au
Sat Aug 17 19:41:22 CEST 2002
"Juza" <r0bbie at libero.it> wrote in message
news:Wjt79.73136$lu5.2099472 at twister1.libero.it...
> It's the same old problem in my code:
> import time
> import socket
> HOST = ''
> PORT = 50007
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.bind((HOST, PORT))
> conn, addr = s.accept()
> print 'Connected by', addr
> while 1:
> data = conn.recv(1024)
> if not data: break
> conn.send("Tutto OK")
> i need a script that every second after the server is in LISTEM print on
> screen * until a client is logged in.
> I have try with the module select but i'm not able to do it.
> Any hint?
as others have said, could you post the code you have tried with 'select'?
IIRC one thing to remember with select is that you don't pass the actual
socket in a list, you pass the file descriptor/number. You can get this by
using the socket objects fileno() method.
so you might have something like
HOST = ''
PORT = 50007
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while not connected:
if s.fileno() in in_socks:
# connected to conn, do whatever
More information about the Python-list