Python socket.accept nonblocking?

前端 未结 2 1493
盖世英雄少女心
盖世英雄少女心 2020-12-01 05:38

Is there a way I can use python\'s socket.accept() in a non-blocking way that simply runs it and lets me just check if it got any new connections? I really don\'t w

2条回答
  •  北海茫月
    2020-12-01 06:18

    You can invoke the setblocking(0) method on the Socket to make it non-blocking. Look into the asyncore module or a framework like Twisted.

提交回复
热议问题