User: Password:
|
|
Subscribe / Log in / New account

TCP friends

TCP friends

Posted Aug 18, 2012 19:58 UTC (Sat) by rvfh (subscriber, #31018)
In reply to: TCP friends by Cyberax
Parent article: TCP friends

> Also, TCP sockets can't be used to pass file descriptors.

Completely OT, but I would love it if you could explain how to pass fd's through UNIX sockets and why this is not possible with INET sockets :-)


(Log in to post comments)

TCP friends

Posted Aug 18, 2012 21:01 UTC (Sat) by viro (subscriber, #7872) [Link]

man 2 sendmsg
man 2 recvmsg
man 7 unix and see the part about SCM_RIGHTS in there
man 3 cmsg for how to set/parse the ancillary data

as to why it's not possible for AF_INET... it's obviously not going to work between different hosts (we are, in effect, passing pointers to opened struct file instances; descriptors are converted to such pointers on the sending end and pointers are inserted into descriptor table by recepient; resulting descriptor numbers are stored in ancillary data returned to userland). And doing that when both ends are on the same host would result in a headache from hell, since we'd need all garbage-collecting machinery for AF_UNIX to apply to AF_INET as well.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds