Needing help with sockets

Irmen de Jong irmen at -NOSPAM-REMOVETHIS-xs4all.nl
Mon Jul 21 21:48:10 CEST 2003


Martin Dion wrote:

> I want to be able to connect on any port on a system and then send and 
> receive commands, by following the protocol rules.
> 
> If I receive data, it must print on the screen.
> 
> It asks for data to send in reply to the data received.
> 
> Once data is sent, it must look if there is data to receive and if not, 
> it must ask the user to send an other string.
> 
> 
> The problem, is that once data is sent, it goes to the receive data loop 
> and blocks until it gets data.

Try the select module.
This allows you to react to things happening on both IO channels
at the same time (user input to send, and data to receive).

--Irmen





More information about the Python-list mailing list