Answer Posted / chaitanya
The best way to do this is with the select() call. This tells the kernel to let you know when a socket is available for use. You can have one process do i/o with multiple sockets with this call. If you want to wait for a connect on sockets 4, 6 and 10 you might execute the following code snippet:
fd_set socklist;
FD_ZERO(&socklist); /* Always clear the structure first. */
FD_SET(4, &socklist);
FD_SET(6, &socklist);
FD_SET(10, &socklist);
if (select(11, NULL, &socklist, NULL, NULL) < 0)
perror("select");
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What does af mean in sockets?
Why do we need sockets?
What is difference between socket and websocket?
How to find other end of unix socket connection?
What is a sae socket?
What's better 6pt or 12pt sockets?
What is a socket address?
system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?
What's the difference between impact sockets and regular sockets?
What is sae socket?
Why does it take so long to detect that the peer died?
How can I write a multi-homed server?
Can a socket have multiple ports?
How can I tell when a socket is closed on the other end?
What are the types of sockets?