Multiple Sockets

Joel Sherrill joel.sherrill at OARcorp.com
Fri Dec 21 17:33:06 UTC 2001



Eric Norum wrote:
> 
> > Bhawani Mittal wrote:
> >
> > Hi All,
> >
> > In FreeBSD, multiple sockets are taken care by the proc structure.
> > But in retem, proc has been implementated as a dummy structure.
> >
> > So, in retem can I operate on multiple sockets ( created by multiple
> > tasks ) simultaneously ?
> > If yes, can anybody tell me how this thing is taken care in RETEM.
> >
> 
> Then answer is yes.  The only restriction is that a given socket can be
> read or written by only one task a time.  This is described in the
> networking supplement to the RTEMS documentation.  I've included the
> salient section below.  The restriction is pretty minor.  I can't think
> of any reason why you'd ever want to have two tasks reading from a
> particular socket at the same time.  Two or more tasks writing to a
> socket at the same time is pretty unlikely too since you'd have problems
> with data coherency.

Wouldn't one of the tasks attempting to read actually block on a mutex
protecting the socket?  Thus from the application's perspective, it 
would look like two are simulateously reading.  One task's read would
just be satisfied before the other. 

> ===============================================================
> 3.4: Application Programming Interface
> 
>       Network Statistics
>       Tapping Into an Interface
>       Socket Options
>       Time Synchronization Using NTP
> 
> 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.
>       The select function only works for file descriptors associated
> with sockets.
>       You must call openlog before calling any of the syslog functions.
>       Some of the network functions are not thread-safe. For example the
> following functions return a pointer to a static buffer which remains
> valid only until the next call:
>       gethostbyaddr
>       gethostbyname
>       inet_ntoa
>             (inet_ntop is thread-safe, though).
>       The RTEMS network package gathers statistics.
>       Addition of a mechanism to "tap onto" an interface and monitor
> every packet received and transmitted.
>       Addition of SO_SNDWAKEUP and SO_RCVWAKEUP socket options.
> 
> --
> Eric Norum                                 eric.norum at usask.ca
> Department of Electrical Engineering       Phone: (306) 966-5394
> University of Saskatchewan                 FAX:   (306) 966-5407
> Saskatoon, Canada.

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the users mailing list