Timers & socket select

I

InuY4sha

Hi,
I've some sockets handled through a select() implemented this way:
/********************************************/
int main(){
......
fd_set pippo;
.....
while(1){
select(maxval+1, &pippo, NULL, NULL, NULL);
if(FD_ISSET(...){
do_this();
if(FD_ISSET(...){
do_that();
}
}
return 0;
}
/********************************************/

The sockets are the stdin and some ipc sockets... what I would need is
to to setup a timer somewhere in that code to handle a synchronous
action to perform while the select of course is still handling the
asynchronous readings.
I saw some functions like alarm, setitimer, getitimer but I don't know
the usage.. and also I don't know what happens when for instance the
socket receives something and the select triggers it to be read (and
some actions to be performed) while at the same time the timer
expires... who as the right to proceed... is the expiration signal put
to wait until the reading from the select (and following actions)
is(are) done ?

I hope you got what I'm tring to say...
Thanks in advance

RM
 
S

santosh

InuY4sha said:
Hi,
I've some sockets handled through a select() implemented this way:
/********************************************/
int main(){
.....
fd_set pippo;
....
while(1){
select(maxval+1, &pippo, NULL, NULL, NULL);
if(FD_ISSET(...){
do_this();
if(FD_ISSET(...){
do_that();
}
}
return 0;
}
/********************************************/

The sockets are the stdin and some ipc sockets... what I would need is
to to setup a timer somewhere in that code to handle a synchronous
action to perform while the select of course is still handling the
asynchronous readings.
I saw some functions like alarm, setitimer, getitimer but I don't know
the usage.. and also I don't know what happens when for instance the
socket receives something and the select triggers it to be read (and
some actions to be performed) while at the same time the timer
expires... who as the right to proceed... is the expiration signal put
to wait until the reading from the select (and following actions)
is(are) done ?

I hope you got what I'm tring to say...
Thanks in advance

This question is best posted to <or a more
specific group, if possible.
 
J

Jens Thoms Toerring

InuY4sha said:
I've some sockets handled through a select() implemented this way:
/********************************************/
int main(){
.....
fd_set pippo;
....
while(1){
select(maxval+1, &pippo, NULL, NULL, NULL);
if(FD_ISSET(...){
do_this();
if(FD_ISSET(...){
do_that();
}
}
return 0;
}
/********************************************/
The sockets are the stdin and some ipc sockets... what I would need is
to to setup a timer somewhere in that code to handle a synchronous
action to perform while the select of course is still handling the
asynchronous readings.

Sorry, but this isn't really a C problem (sockets or the select()
function aren't even mentioned in the C standard) but a problem
of the API of what looks like UNIX. Thus asking in a newsgroup
that deals with UNIX would be wiser, e.g. in comp.unix.programmer.

<off-topic>
See the documentation of select(), you can pass it a timeout
value as the last argument, making select() return when either
you can read from one of the file descriptors or the timeout
limit has been reached. So you don't need any extra timers. If
you need more details I or somebody else will answer your ques-
tions in comp.unix.programmer.
</off-topic>
Regards, Jens
 
I

InuY4sha

See the documentation of select(), you can pass it a timeout
value as the last argument, making select() return when either
you can read from one of the file descriptors or the timeout
limit has been reached. So you don't need any extra timers. If
you need more details I or somebody else will answer your ques-
tions in comp.unix.programmer.
</off-topic>
Regards, Jens

Cool! This saves a lot of "extra researching"!!!! Thank you

[PS:Yes sorry about being off topic... I'm so dude that I don't know
the difference between a C problem and a UNIX...
I mean.. I know I'm talking about sys calls.. but I thought this could
also be somehow C concerning... and that anyway there was always C
behind them also..excuse my ignorance :( ]
 
R

Richard Heathfield

InuY4sha said:
Cool! This saves a lot of "extra researching"!!!! Thank you

No, it doesn't save you anything.

Jens (and if I am any judge of character, I think he will be the first
to agree with me here) may be mistaken, perhaps in a subtle way that
will bite you later. How will you know, except by finding some experts
in the field and checking with them? That may mean getting a good book
on the subject, or it may mean finding a newsgroup where your question
/is/ topical. Peer review on C questions here in comp.lang.c is first
class, but peer review on non-C questions is notoriously lacking.
 
R

Richard

Richard Heathfield said:
InuY4sha said:


No, it doesn't save you anything.

Jens (and if I am any judge of character, I think he will be the first
to agree with me here) may be mistaken, perhaps in a subtle way that
will bite you later. How will you know, except by finding some experts
in the field and checking with them? That may mean getting a good book
on the subject, or it may mean finding a newsgroup where your question
/is/ topical. Peer review on C questions here in comp.lang.c is first
class, but peer review on non-C questions is notoriously lacking.

In your haste to post you seem not to have noticed that Jens already
directed him to comp.linux.programmer for more information. Still, at
least you got your tuppence worth.
 
R

Richard Heathfield

Richard said:
In your haste to post you seem not to have noticed that Jens already
directed him to comp.linux.programmer for more information.

No, I didn't miss his redirection (which was actually to
comp.unix.programmer, not comp.linux.programmer - in your haste to
post, you appear to have got your facts wrong again). From the OP's
response, however, I thought it likely that the *OP* had missed the
redirection. That is why I responded as I did.
Still, at least you got your tuppence worth.

Still trolling, I see.
 
R

Richard

Richard Heathfield said:
Richard said:



No, I didn't miss his redirection (which was actually to
comp.unix.programmer, not comp.linux.programmer - in your haste to
post, you appear to have got your facts wrong again). From the OP's

What "facts wrong again"? I small error, but it didn't matter - the
point was valid.
response, however, I thought it likely that the *OP* had missed the
redirection. That is why I responded as I did.

No you responded as you did to try and get your customary moral high
ground and to make it clear that none of the current issues being
discussed has phased you in any way away from your chosen path as the
group's director.
Still trolling, I see.

It's interesting that anyone that disagrees with you is a troll. By the
normal definition, it is you who are the troll.
 
R

Richard Heathfield

Richard said:
It's interesting that anyone that disagrees with you is a troll. By
the normal definition, it is you who are the troll.

If you took the trouble to read this newsgroup a little more closely,
you would realise your mistake. But to make it easier for you, here is
a little list giving just a couple of dozen of the very many
comp.lang.c subscribers who have disagreed with me:

Martin Ambuhl, Richard Bos, Dann Corbit, Chris Dollin, Bill Godfrey,
"Flash" Gordon, Doug Gwyn, Chris Hills, Lawrence Kirby, Ben Pfaff, Dan
Pop, Brian Rodenborn, Will Rose, Michael Rubinstein, Eric Sosman,
Richard Stamp, Bjarne Stroustrup, Steve Summit, David Thompson, Keith
Thompson, Richard Tobin, Chris Torek, Stefan Wilms, Dik Winter.

I don't consider any of the people on this list to be trolls. Nor is the
list exhaustive by any stretch of the imagination.

*Some* people who disagree with me are indeed trolls. But other people
who disagree with me are not. And in fact there are people who I do
consider to be trolls with whom, nevertheless, I occasionally find
myself in agreement. You are rapidly becoming an example.
 
R

Richard

Richard Heathfield said:
Richard said:


If you took the trouble to read this newsgroup a little more closely,

Again, more assumptions. I do read this NG closely.
you would realise your mistake. But to make it easier for you, here is
a little list giving just a couple of dozen of the very many
comp.lang.c subscribers who have disagreed with me:

Yes, well, clearly I didn't mean "everyone" everyone....

Anyway, it's obvious that you do see yourself as some paragon of virtue
and the defender of the one true faith and no amount of cajoling will
make you open your eyes to your posting style and technique so off you
go on your merry little way. I'm sure there's a nOOb just around the
corner who needs to be talked down to, scolded and generally slapped
about a bit so that he knows who's boss.

*thread score demoted*
 
I

InuY4sha

I don't consider any of the people on this list to be trolls. Nor is the
list ...

Man don't put so much effort.. I just needed a piece of answer.. I
don't need a whole book or a specialist... what I was replied with was
fine for me .. so np at all..
Ciao :)
 
K

Kenny McCormack

Richard said:



If you don't mean it, don't say it.

Um, er, poetic license. Here in the states, you will often here people
say "Everyone likes 'American Idol'", but obviously, not EVERYONE does.
 
R

Richard

Um, er, poetic license. Here in the states, you will often here people
say "Everyone likes 'American Idol'", but obviously, not EVERYONE does.

Heathfield is being his normal asinine, pedantic, self absorbed
self.

He likes to pull the Captain Logic lines to further promote himself as
programmer extraordinaire.

Where I am sat "the entire summer is a wash out". He would pull me up
and remind me that we had a day in June which wasn't high winds and
torrential rain. And thus deduce, in his own inimitable way that I am a
troll and a liar.
 
K

Kenny McCormack

Heathfield is being his normal asinine, pedantic, self absorbed
self.

He likes to pull the Captain Logic lines to further promote himself as
programmer extraordinaire.

Where I am sat "the entire summer is a wash out". He would pull me up
and remind me that we had a day in June which wasn't high winds and
torrential rain. And thus deduce, in his own inimitable way that I am a
troll and a liar.

He's so clever. Isn't he just dreamy?
 
K

Kelsey Bjarnason

[snips]

What "facts wrong again"? I small error, but it didn't matter - the
point was valid.

And you make the very point being made in the "No, it doesn't save you
anything" post. The poster (Jens) had given a response which was
potentially useful... but may well have contained a small error, one which
is considerably less likely to be caught *here* where many don't use the
tools in question, and considerably *more* likely to be caught in a group
dedicated to the use of the particular tools, OS, libraries and suchlike
the questioner is asking about.

RH's response was to point out that the answer, while *potentially*
helpful, is also *potentially* error-prone, as it is not being examined in
a forum where people knowledgeable in that specific tool set congregate;
had it been asked there, subtle issues which may be overlooked here are
much more likely to be caught.

You made a "slight error" in getting the redirection wrong even when you
had the information right at your fingertips, nothing subtle involved.
Why, then, would you expect actually subtle errors or oversights to be
caught in fora not populated by people skilled in the particular toolset?

You want *C* questions answered, ask here. You want *nix questions
answered, ask in a *nix group and so forth; this is the best way to ensure
you get correct information without overlooking things - and as you show
above, it's trivial to overlook things, even when they're smack-bang
in-your-face.
 
C

CBFalconer

Richard said:
Heathfield is being his normal asinine, pedantic, self absorbed
self.

He likes to pull the Captain Logic lines to further promote
himself as programmer extraordinaire.

Where I am sat "the entire summer is a wash out". He would pull
me up and remind me that we had a day in June which wasn't high
winds and torrential rain. And thus deduce, in his own inimitable
way that I am a troll and a liar.

Enough. You have attained the PLONK file.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top