socket question
maximilianscherr
MaximilianScherr at T-Online.de
Sun Jan 20 15:23:06 EST 2002
Thank you.
--- In python-list at y..., Chris Liechti <cliechti at g...> wrote:
> "maximilianscherr" <MaximilianScherr at T...> wrote in
> news:mailman.1011552989.3398.python-list at p...:
> > have seen it, but don't really understand it, like if i do a
> > socket.recv() does it wait until it receives data?
>
> normally sockets are blocking so yes it waits for data. the socket
can be
> changed to non-blocking in that case it returns immediately an
empty
> string. not that recv(n) does receive up to n characheters.
receiving is
> therefore done in a loop. its also common to receive until a
special
> character/prompt is received.
> note that the same applies to send. in python 2.2 there is sendall
which
> sends everything, with send it returns the truely sent characters.
i use:
>
> s = "messy"
> while len(s):
> s = s[conn.send(s):]
>
> there is also makefile. that way you can send and receive like its
> stdin/stdout or any other file (write, read). however i never used
this.
>
> chris
> --
> Chris <cliechti at g...>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list