How can I use socketpair (C++ Linux) to have two way communication between (two) applications? Both applications will run on same hardware, hence I am looking for implementation of socketpair on same platform.

I have a simple test program which "connects two sockets" and passes the data between them.

How do I make them aware that each socket is in DIFFERENT application?

I have some success doing same task using bluetooth (apps run on different hardware), now I would like to apply similar approach on same hardware.

Suggestions are appreciated.

  • 2
    Your question is not clear. Include what you have tried, and what went, wrong. – ctrl-alt-delor Mar 13 '20 at 21:29

If you use this call. Then you will have a few choices (there may be others):

  • Call fork, so that you have two processes with the sockets. Then you can have one end used by the parent, and one by the child.
  • Alternatively use a named socket. Then one end is owed by the creator, and the other is attached to a file-name.
  • Thanks for reply. – anne Mar 15 '20 at 19:29
  • Thanks for reply. I am currently running the primary application (client) communication to the secondary (server). In server I used socketpair and fork. The child is managing the client / server Bluetooth connection and the parent does the graphics (OpenGL). Works in principle, still haveing some timing issues. – anne Mar 15 '20 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.