0

I've got a server with a number of worker processes forked initially with the server setup. The sever accepts connections, and must pass the descriptor to a worker.

What's an easiest way that I could later on share the socket descriptor of a client's connection with a worker?

Sajad
  • 182
  • 1
  • 11
  • 1
    See https://stackoverflow.com/questions/28003921/sending-file-descriptor-by-linux-socket/ for a way to send an open file descriptor to another process. Other examples can be found via Google search: https://www.google.com/search?q=sendfd – Andrew Henle Apr 15 '18 at 00:40
  • Thanks a lot. Unix Network Programming reference really helped. – Sajad Apr 15 '18 at 12:53

1 Answers1

1

I would suggest you to run workers with specific port range and use socketpair to share the socket descriptor from another port. Also you can block those worker ports for external communication for the sake of good security pratices.

CanCode
  • 154
  • 2
  • 10