select call on a UDP socket with BSD library?

Ian Caddy ianc at goanna.iinet.net.au
Tue Sep 1 03:31:06 UTC 2020


On 1/09/2020 10:48 am, Chris Johns wrote:
> On 1/9/20 6:14 am, Cudmore, Alan P. (GSFC-5820) wrote:
>> I am having problems using the “select” call with an RTEMS + LibBSD network socket.
>>
>> I’m trying to use “select” to check the socket (using a timeout of zero), but
>> when I call select I get a -1 return code with EBADF errno.
> I suspect you have hit the FD set size limit.
>
>> The fd in this instance is 77 and I have RTEMS setup for 200 file descriptors.
>> Are there any other LibBSD configuration parameters I should be aware of?
>> When I build a SPARC/LEON3 BSP with the RTEMS legacy network stack, the select
>> call seems to work. Admittedly I am just doing this on the loopback interface on
>> QEMU since I do not have a real or simulated ethernet device to use. But the
>> select call seems to work as I would expect in this instance.
> What is the fd for that stack? I suspect the fd is less than 64.

I can confirm what Chris is saying and that the RTEMS4.10 stack has a FD 
setsize of 64 as well, but the old network stack gets the fd's from the 
bottom, so as long as you have less than 64 files and sockets open you 
will be OK.

With LIBBSD, it seems much more random and even getting one of more 
sockets can get you over the default 64 limit, as you are seeing with 
the fd=77.

With LIBBSD we have to use the FD_SETSIZE for all our code compilation 
to override the tiny default.

It is got around in more modern code by using poll instead of select, 
but we have a lot of legacy code that still uses select which requires 
the FD_SETSIZE parameter.

regards,

Ian Caddy




More information about the devel mailing list