I'm trying to give an already running child process access to a socket I'm using in the parent process. This must be done in C/C++ and on Windows and Linux. Currently I only know of Unix domain sockets for sending the socket's file descriptor to the child process which is perfectly suitable but only works on Linux. But I haven't found a solution that works on both platforms yet.
Asked
Active
Viewed 244 times
0
-
1Have you looked at Boost? http://www.boost.org/ – Nick Feb 14 '14 at 09:16
-
I looked at it briefly but I couldn't find a hint whether it is able to send TCP sockets on windows. Do you know if this is possible? – HardcorEViruS Feb 14 '14 at 09:18
-
2Your title is too broad. "IPC" = "InterProcess Communication", and also includes shared memory, pipes and other things. What you want is just a network library. You should check Boost.Asio. – Synxis Feb 14 '14 at 09:19
-
possible duplicate of [Best C/C++ Network Library](http://stackoverflow.com/questions/118945/best-c-c-network-library) – Synxis Feb 14 '14 at 09:20
-
Have you tried D-bus, it is Linux and Windows – Brandin Feb 14 '14 at 09:21
-
@Brandin I'm currently using D-bus with Qt and I don't really need Qt for this but I couldn't find whether D-Bus for windows can send sockets. – HardcorEViruS Feb 14 '14 at 09:22
-
@Synxis As it seemd Boost.Asio can only send sockets over Unix Domain Sockets which doesn't work on windows – HardcorEViruS Feb 14 '14 at 09:24
-
1Boost.Asio works perfectly fine on Windows. – Synxis Feb 14 '14 at 09:27
-
@HardcorEViruS It sounds like you need a network library like others mentioned. For a simple solution you could look at Apache Portable Runtime it has network IO socket functions – Brandin Feb 14 '14 at 09:28
-
ZeroMQ might be another contender http://zeromq.org/ – Nick Feb 14 '14 at 09:32
-
@Nick As per [this Answer](http://stackoverflow.com/a/15670098/2560791) ZeroMQ doesn't have the capabilities to send sockets at least on windows – HardcorEViruS Feb 14 '14 at 09:44
-
@Synxis Boost.Asio seems to only be able to send socket file descriptors on Linux using Unix Domain Sockets but not on Windows – HardcorEViruS Feb 14 '14 at 09:45
-
@HardcorEViruS I see you've changed your question - it wasn't clear originally what you were trying to do. I've flagged it for reopening but you'll need more voters. Alternatively ask a new question. – Nick Feb 14 '14 at 09:59
-
I agree with Nick, I voted to reopen it. – Synxis Feb 14 '14 at 10:59
-
Look at `WSADuplicateSocket`. – n. m. could be an AI Feb 14 '14 at 11:30