AC78 AC78 - 1 year ago 94
Linux Question

Can I pass a UDS file descriptor through another UDS connection in c or c++

I am trying to pass an established connection Unix Domain Socket file descriptor from process A to process B through another Unix Domain Socket connection, with no luck
although a tcp socket is passed with no problem.
Is there a reason to it or am I doing something wrong?
Both are passed through ancilary message

Answer Source

Socket file descriptor (just like a regular file descriptors) have absolutely no meaning outside the process that properly created them. When you send a fd to other process, you are just sending a bunch of bytes - nothing more, nothing less.

The only way you can move a working fd from one process to another is to fork() a process containing the fd to be passed.

If you want some process to connect to a particular Unix socket you should pass a unix socket file system entry name to that process. The receiving process can properly create a socket and make a connection afterwards.

I don't know why didn't you have problems with passing a tcp socket fd. Perhaps if you post the relevant parts of your code the reason will be revealed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download