RTEMS socket programming (select usage etc.)
Eric Norum
norume at aps.anl.gov
Thu Nov 13 16:47:17 UTC 2003
Eric Norum wrote:
> Jonas Moberg wrote:
>
>>> In the Network documentation I read the following information:
>>
>>
>> "The RTEMS network package provides almost a complete set of BSD network
>> services. The network functions work like their BSD counterparts with
>> the following exceptions:
>> A given socket can be read or written by only one task at a time. "
>>
>> Would this state that one can use only one task for reading and writing
>> or one task that reads and
>> another task that writes?
>> If we don't want to do a traditional server that reads, processes data
>> and then writes to a socket
>> by one thread what, is then the recommended way?
>> We would like to asyncronously read and write from several tasks.
>> The rtems select implementation says that usage should be avoided if
>> possible.
>>
>
> Sorry for the cryptic documentation. Yes, it is quite acceptable to
> have one task reading and another task writing a single socket. What is
> not acceptable is to have two or more tasks trying to read a single
> socket at the same time. It is also unacceptable to have two or more
> tasks trying to write a single socket at the same time.
>
And to clarify my clarification (!) it is fine to have multiple tasks each reading their own socket. You can accept() a new socket in one thread, then spawn worker thread(s) to read it in another thread and perhaps write it in yet another thread with no problems. There can be as many of these worker threads, each with their own socket, as memory will allow.
--
Eric Norum norume at aps.anl.gov
Advanced Photon Source Phone: (630) 252-4793
Argonne National Laboratory
More information about the users
mailing list