Most efficient way to handle a client connection (socket programming)

后端 未结 7 771
走了就别回头了
走了就别回头了 2021-01-18 11:26

For every single tutorials and examples I have seen on the internet for Linux/Unix socket tutorials, the server side code always involves an infinite loop that checks for cl

7条回答
  •  独厮守ぢ
    2021-01-18 11:49

    In addition to what has already been posted, it's fairly easy to see what is going on with a debugger. You will be able to single-step through until you execute the accept() line, upon which the 'sigle-step' highlight will disappear and the app will run on - the next line is not reached. If you put a breadkpoint on the next line, it will not fire until a client connects.

提交回复
热议问题