why select() always return 0 after the first timeout

后端 未结 5 1426
难免孤独
难免孤独 2020-12-01 22:17

I have a problem about select function when I worked on a Linux socket program. The select function worked fine as the man page says if the client connected the server side

5条回答
  •  失恋的感觉
    2020-12-01 22:34

    I've got the same trouble in my similar codes. I followed the suggestion of doing initialization each time before calling select() and it works. In codes at this case, just bringing the two lines into loop will make it work.

    FD_ZERO(&read_set);
    FD_SET(servSock, &read_set);
    

提交回复
热议问题