By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,871 Members | 2,595 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,871 IT Pros & Developers. It's quick & easy.

Select function

P: n/a
Hi all,

My problem is: I'm waiting with select() on a socket array, when data
is written in one of the sockets the select awakes. The problem is that
untill it finishes I can't listen to the other sockets (I'm using only
one task).

I've heard that there is an option for a non blocking select, is it
true?
If not does anyone have any idea?

Thanks in advance...

Apr 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a

Bari wrote:
Hi all,

My problem is: I'm waiting with select() on a socket array, when data
is written in one of the sockets the select awakes. The problem is that
untill it finishes I can't listen to the other sockets (I'm using only
one task).

I've heard that there is an option for a non blocking select, is it
true?
If not does anyone have any idea?


C++ knows nothing about sockets, so you're off-topic in this group
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

You need to ask a group dedicated to programming on your platform, or
to whatever third party library you're using for sockets.

Gavin Deane

Apr 20 '06 #2

P: n/a
Thanks...

Apr 20 '06 #3

P: n/a
Bari wrote:
Hi all,

My problem is: I'm waiting with select() on a socket array, when data
is written in one of the sockets the select awakes. The problem is that
untill it finishes I can't listen to the other sockets (I'm using only
one task).

I've heard that there is an option for a non blocking select, is it
true?
If not does anyone have any idea?


The very idea of select is to wait on multiple file descriptors (e.g.
sockets) at once. You have to put the other sockets in your file
descriptor set. A non-blocking select does not make much sense.

Apr 20 '06 #4

P: n/a
On 20 Apr 2006 02:10:22 -0700 "Bari" <ba*******@gmail.com> waved a wand
and this message magically appeared:
My problem is: I'm waiting with select() on a socket array, when data
is written in one of the sockets the select awakes. The problem is that
untill it finishes I can't listen to the other sockets (I'm using only
one task).

I've heard that there is an option for a non blocking select, is it
true?


Whilst this is off topic as comp.lang.c++ deals only with standard C
++, the function below might be of use. In future, use one of the
UNIX oriented programming newsgroups for advice.

void setnonblocking(int sock)
{
int opts;

opts = fcntl(sock,F_GETFL);
if (opts < 0) {
perror("fcntl(F_GETFL)");
exit(EXIT_FAILURE);
}
opts = (opts | O_NONBLOCK);
if (fcntl(sock,F_SETFL,opts) < 0) {
perror("fcntl(F_SETFL)");
exit(EXIT_FAILURE);
}
return;
}
--
http://www.munted.org.uk

Take a nap, it saves lives.
Apr 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.