On Mon, Mar 14, 2011 at 2:45 PM, Paolo Bonzini <bonz...@gnu.org> wrote: > On 03/14/2011 02:36 PM, Bastien ROUCARIES wrote: >> >> Or you could ask throught the socket, the process id of the receiving >> process than send the handle. >> >> Remember: >> It is assumed that the two sides have coordinated and agreed to >> transfer a file descriptor already, so that the sendfd is met with a >> recvfd instead of an ordinary read. > > No, you cannot unfortunately. Say that process 1 will do this: > > send "getfd\n" > sendfd > > then the following will work on Unix in process 2: > > recv(socket, buf, 512) => return 6, buf = "getfd\n" > parse getfd > recvfd > > If the recvfd info is sent on the normal channel (i.e. not out-of-band), > process 2 is going to fail like this: > > recv(socket, buf, 512) => return 17, buf = "getfd\n0x12345678\0" > parse getfd > recvfd fails, or even worse it blocks (possibly forever) > even if recvfd doesn't block, parsing 0x12345678\0 fails
Why ? It is like sending and receiving data throught a protocol. i will emulate AF_UNIX by tcp socket over localhost with TCP_NODELAY And we already send data using unix fd passing Bastien > > Paolo >