When using select call on many sockets, how to check if one of them is closed

P

prashantkumar1982

I am using the select call to read from many sockets. I don't want to
call read on every socket to check if it is closed, as it defeats the
purpose of using the select call.
Is there any way to know whether one of the sockets have been closed,
without actually testing each socket.
 
K

Ken Human

I am using the select call to read from many sockets. I don't want to
call read on every socket to check if it is closed, as it defeats the
purpose of using the select call.
Is there any way to know whether one of the sockets have been closed,
without actually testing each socket.

C doesn't know what a socket is. Check a newsgroup or forum that deals
with whatever networking library you're using. alt.winsock.programming
might be a good place to start.
 
W

Walter Roberson

I am using the select call to read from many sockets. I don't want to
call read on every socket to check if it is closed, as it defeats the
purpose of using the select call.
Is there any way to know whether one of the sockets have been closed,
without actually testing each socket.

select() is not one of the routines defined by the C standards.
It is therefore not generally considered to be on-topic here.

We wouldn't be able to answer your question without knowing
the operating system (and version) .

If your OS considers the closing of a socket to be an
"exceptional condition" then you may be able to examine the
exception bitset and check only the fds marked as being in exception.
Some would argue, though, that close is a normal condition, not
an exceptional one (exceptional might be things like a TCP RST
or a pipe closing), so you would need to check the details
for whichever operating system you happen to be using (which you
have left us to guess...)
 
K

Keith Thompson

select() is not one of the routines defined by the C standards.
It is therefore not generally considered to be on-topic here.

We wouldn't be able to answer your question without knowing
the operating system (and version) .

Correction: Even if we know what operating system you're using, the
best we can do is tell you which newsgroup can help you.
 
M

Michael Wojcik

If your OS considers the closing of a socket to be an
"exceptional condition" then

.... it follows neither the POSIX nor Winsock standards, so the OP
would *definitely* need a platform-specific group.

If, on the other hand, the OP's implementation of sockets does follow
either of those standards, he could find help at comp.protocols.tcp-ip,
as well as at platform-specific groups. (Or, for that matter, in any
of a great number of resources, such as FAQs and books, both of which
should be consulted by anyone trying to use any of the sockets APIs.)

And that, once again, is why we shouldn't try to answer off-topic
questions here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top