Sunday, 30 August 2020

Re: [gccsdk] af_unix socketpair

Hi Lee,

> > Does sockets only exist in the current task? If I do
> > "wimp_start_task", can I use my socket in the new task?
>
> No, although the underlining OS socket is I believe system wide,
> Unixlib refers to them by file descriptor and these are allocated
> locally within each task rather than system wide as Linux might do, so
> you can't pass the file descriptors between tasks.

Unix (Linux) allocates file descriptors within a process, that's why
they all start at zero and the lowest unused one within the process is
allocated. But I think you know that and it's terminology where we
differ. An FD is an index into the process's FD table and that entry
references an element in the kernel's single file table, FT.

Unix can pass a file descriptor from one process to another. What's
really being passed is the reference to the kernel's FT entry. Thus the
FT entry may be referenced by a different FD in the receiving process,
e.g. 42 becomes 314.

> You may be able to pass the underlying OS socket between tasks, but
> Unixlib in the task you pass it to would not be aware of it; I don't
> think Unixlib can adopt an existing OS socket.

So if Unixlib wanted to grow the ability to mimic Unix in this regard,
it would be by supporting the SCM_RIGHTS ancillary message over a Unix
domain socket. See unix(7) on Linux.

--
Cheers, Ralph.

_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK

No comments:

Post a Comment