-
select
On a couple of occations (extremely rare) the below code produces an
S_iosLib_INVALID_FILE_DESCRIPTOR (0xD0003) error code. In other words,
the code works fine 99,999999% of the time. This happens during normal
runtime (not during booting). Struggling to understand why this is
happening and howto debug this further. Appreciate any help.
switch(select(tcp->socket + 1,
&read_set,
NULL,
NULL,
&timeout))
{
case 0:
//Timeout
break;
case 1:
//Do recv
break;
default:
//Set error
break;
}
-
Re: select
Hi,
Not sure but could it be the case that one of the socket in read_set
is closed for some reason? If it would have happened at the boot time
I would have suspected that you didn't call FD_ZERO on read_set. But
since that is not the case I think you should check your code to see
if any of the fd in read_set is closed in some code leg and you didn't
clear it from read_set.
Best Regards
VKG | Ritsoft Technologies
-
Re: select
Thank you for your reply.
Apologises for not adding all code. FD_ZERO is being run just before
the switch case.
fd_set read_set;
FD_ZERO(&read_set);
FD_SET(tcp->socket, &read_set);
How do you suggest I could check the state of the fds in read_set?
Another thing, did a google search on the error message and according
to [1] select(...) is not even suppose to output this error type. Can
I read anything into this?
[1] - [url]http://www.slac.stanford.edu/exp/glast/flight/sw/vxdocs/vxworks/errno/errnoAlphaList.html#S_iosLib_INVALID_FILE_DESCRIPTOR[/url]
On 3 Jan, 12:46, VKG Ritsoft Technologies <vkg.rits...@gmail.com>
wrote:[color=blue]
> Hi,
>
> Not sure but could it be the case that one of the socket in read_set
> is closed for some reason? If it would have happened at the boot time
> I would have suspected that you didn't call FD_ZERO on read_set. But
> since that is not the case I think you should check your code to see
> if any of the fd in read_set is closed in some code leg and you didn't
> clear it from read_set.
>
> Best Regards
> VKG | Ritsoft Technologies[/color]
-
Re: select
Hi,
I am not sure why its not documented on the link but as far as I know
when you call select it does ioctl with function code FIOSELECT that
in turns checks for the validity of each fd in the fdset by looking in
to fd table. And if not found returns error
S_iosLib_INVALID_FILE_DESCRIPTOR (0xD0003).
Mostly select is used when you have to monitor activities on multiple
sockets. So I assumed that you are having several socket fd in
read_set and was suggesting to verify in the code that if there is any
fd which is actually closed for some reason but corrosponding to that
FD_CLEAR is not done. But from your example it seems that you have
only one socket set in the readset so my assumption is wrong. Not sure
why do you need select for one socket so can't say anything.
Best Regards
VKG | Ritsoft Technologies