0

I would like to know if it is possible to create unix domain socket, with Socket_Stream configuration where server and client binds their own sockets so that they could be able to send their sockaddr information.

In other words I would like to send sockaddr from one side to another. With that I would like to control and distinguish multiple clients on the server side.

  1. However as I understand you cannot receive sockaddr information in connection-mode. In other words you cannot use accept-connect while sending Unix socket sun_path information as sockaddr. Is it right conclusion?

  2. As you can see in question below, It is possible to send sockaddr by binding both sockets and using sendto recv function. But Is it possible to use it also with connect-accept mod. since I could not be able to run that example with SOCK_STREAM (connect accept doesn't allow SOCK_DGRAM) configuration. Is there a way to do this

Sockets, Unix Domain UDP C++ recvfrom fail to populate the source address

Meric Ozcan
  • 678
  • 5
  • 25
  • To send information between unrelated processes (even processes running the same program) you need some kind of channel to transmit that information. Like a `AF_LOCAL` socket (or a pipe, or other [IPC](https://en.wikipedia.org/wiki/Inter-process_communication) method). If you don't already have such a channel, then you can't transmit information. So it seems you have a kind of [catch-22](https://en.wikipedia.org/wiki/Catch-22_(logic)) situation going on: You need to create a connection, but you can't create it unless you already have a connection. – Some programmer dude Aug 29 '20 at 14:48
  • @Some programmer dude hello yes. But if there is a way to do this with connect-accept mode I would love to listen other wise, I plan to do this: Main process will send its own path to other side-Processes in his first message, other process will knew it his MainProcess is awakened and Side Processes will also send connection request to Main process. – Meric Ozcan Aug 29 '20 at 14:56
  • why not simply make a TCP socket on localhost interface, it should be as efficient as a unix socket (besides making the code more portable) – Yann TM Aug 29 '20 at 15:07
  • Unix domain sockets are faster way to do this I believe @YannTM – Meric Ozcan Aug 29 '20 at 15:08
  • depends on your throughput whether this is significant enough to matter : https://stackoverflow.com/questions/14973942/tcp-loopback-connection-vs-unix-domain-socket-performance#:~:text=When%20the%20server%20and%20client,(on%20Linux%20for%20instance). If you really want efficiency on a stream communication that only work on unix Named Pipes (mkfifo) should be even better you just exchange file (named pipes) names as addresses. – Yann TM Aug 29 '20 at 15:17
  • Thank u man @YannTM, it is decided already. – Meric Ozcan Aug 29 '20 at 15:20
  • I believe no one will answer my question anyway. Could u plz upvote so that some one can see this. Even a No answer as a fact, would be nice @YannTM – Meric Ozcan Aug 29 '20 at 15:38
  • Sorry my answer is not really answering your question since it is proposing workarounds. You should put a bounty on the question to attract more answers. – Yann TM Sep 04 '20 at 17:28

0 Answers0