I am facing a problem using the select function in Unix.
I have a server that waits for for a connection. First I add the listening socket file descriptor listener
to the fd_set readfds
using FD_SET(listener, readfds)
and then I use that in select()
.
When I get a connection, I call accept()
and set the readfds
in select with the accepted file descriptor and start receiving the data from connection. However, when I check the code in strace, The select doesn't show the listener in the readfds
while select()
is executing a second time.
Do I need to set the listener file descriptor again using FD_SET(listener, readfds)
before calling select()
again?
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…