Unix Technical Forum

How to handle Potential Problems with select()

This is a discussion on How to handle Potential Problems with select() within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi all, I have a problem I hope someone can help me with. If I make a call to ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 03:07 AM
sheadley
 
Posts: n/a
Default How to handle Potential Problems with select()

Hi all,

I have a problem I hope someone can help me with. If I make a call to
select, and the operating system tells me that there is data to be
read on one of my sockets, how do i handle the problem when select
says there is data to be read but FD_ISSET reports no activity on any
socket? Is it possible to some how reset select to not report that
socket as ready for reading again? This is my problem. select returns
saying there is data, but when I do an FD_ISSET to find out which
socket is ready no sockets have info ready to be read. Is it possible
to tell which fd select is reporting is ready, or can I reset select
altogether? Please any help would be appreciated


Steven H.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 03:07 AM
Slor
 
Posts: n/a
Default Re: How to handle Potential Problems with select()

Despite all prevention efforts, sheadley@omiintl.com (sheadley) wrote in
news:7fd5a68.0408250733.5024a8e3@posting.google.co m:

> Hi all,
>
> I have a problem I hope someone can help me with. If I make a call to
> select, and the operating system tells me that there is data to be
> read on one of my sockets, how do i handle the problem when select
> says there is data to be read but FD_ISSET reports no activity on any
> socket? Is it possible to some how reset select to not report that
> socket as ready for reading again? This is my problem. select returns
> saying there is data, but when I do an FD_ISSET to find out which
> socket is ready no sockets have info ready to be read. Is it possible
> to tell which fd select is reporting is ready, or can I reset select
> altogether? Please any help would be appreciated
>
>
> Steven H.
>


I'm not in front of my AIX box at the moment, so I cannot verify this, but
assuming select() is similar to the Linux & Windows implementations:

Three independent sets of descriptors are watched. Those listed in
readfds will be watched to see if characters become available for read-
ing (more precisely, to see if a read will not block - in particular, a
file descriptor is also ready on end-of-file), those in writefds will
be watched to see if a write will not block, and those in exceptfds
will be watched for exceptions. On exit, the sets are modified in
place to indicate which descriptors actually changed status.

According to that, shouldn't your list of sockets be modified in place by
the function call to let you know know which fd(s) are considered ready to
read?

--
Slor
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 03:07 AM
Nils Weller
 
Posts: n/a
Default Re: How to handle Potential Problems with select()

In article <7fd5a68.0408250733.5024a8e3@posting.google.com> , sheadley wrote:
> I have a problem I hope someone can help me with. If I make a call to
> select, and the operating system tells me that there is data to be
> read on one of my sockets, how do i handle the problem when select
> says there is data to be read but FD_ISSET reports no activity on any
> socket? Is it possible to some how reset select to not report that
> socket as ready for reading again? This is my problem. select returns
> saying there is data, but when I do an FD_ISSET to find out which
> socket is ready no sockets have info ready to be read. Is it possible
> to tell which fd select is reporting is ready, or can I reset select
> altogether? Please any help would be appreciated


It's hard to draw any conclusions from your post, because the behavior
you describe matches neither the industry standards specifications, nor
the implementations of select() I have seen (yes, I have used select()
on AIX as well, and it did not exhibit this behavior.)

From your description it sounds like you used the return value of
select() properly, but just to make sure: select() returns 0 on timeout,
-1 on failure, and the number of ready descriptors on success. What
value(s) are you getting exactly and how many sockets do you have? How
frequently does this problem occur? Are you aware of the fact that an
EOF condition is considered to be ``ready for reading'' as well (in
which case FD_ISSET() should report activity though)?

Have you initialized your descriptor set using FD_CLR() before you
called select()? Is your program small enough to post it here, or could
you take out the select() bits and use them to produce a minimal program
that reproduces your problem?

--
My real email address is ``nils<at>sipoc<dot>de''
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 03:07 AM
Nils Weller
 
Posts: n/a
Default Re: How to handle Potential Problems with select()

In article <2p4gdsFgjppmU1@uni-berlin.de>, Nils Weller wrote:
> Have you initialized your descriptor set using FD_CLR() before you

^^^^^^^^
Of course, I meant FD_ZERO().

--
My real email address is ``nils<at>sipoc<dot>de''
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 07:35 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com