socket programming

Chris Angelico rosuav at gmail.com
Fri May 3 23:56:01 EDT 2013


On Sat, May 4, 2013 at 1:37 PM, Pedro <pedro at ncf.ca> wrote:
> On Friday, May 3, 2013 10:23:38 PM UTC-4, Chris Angelico wrote:
>> The accept() call should block. It's not going to spin or anything. If
>>
>> you need to monitor multiple sockets, have a look at select().
>
> Thanks Chris, can you elaborate on the accept() call should block?

When you call accept(), your program stops running until there's a
connection. It's like calling input() (or raw_input()) and your
program stopping until you type something. You can disable that by
setting the socket nonblocking, but I don't think you're doing that
here (and you probably don't want to).

Consider the accept() call to be, effectively, like reading from the
bound socket. In many ways it functions that way.

ChrisA



More information about the Python-list mailing list