Design using fork () and a TCP connection in C

I have a question regarding how to create the following system:

My system is built from several clients who listen to the environment. When the sound threshold is violated, they send their information to a server that has children who listen to each connection. To perform the necessary calculations, the server requires information from all clients.

Currently, the server runs on UNIX and has branched connections. They work independently.

What I want to do is tell the parent (on the server) that the information has been sent, and now it's time to process it. How am I supposed to do this?

I am thinking about possible ways to do this:

  • Using signal() on Unix to somehow tell parents that something happened
  • Convert to streams and use some waiting and notification features

A signal is preferable, but I cannot figure out how to do this efficiently. Because the following may happen on my system:

  • If all clients have successfully sent information to their child servers, how can I tell my parents that I am ready in efficient mode? I don't know / I'm not sure how he will handle them.
  • The server may not receive information from all clients. Therefore, the parent should wait for some time for all children, but not too long. So, I guess some kind of timer?
+1
c design fork sockets tcp
source share
2 answers

Do not use a plug or use signals. Use a thread pool.

+3
source share

How about a Unix Domain Socket for interactions between processes between children and a father?

http://en.wikipedia.org/wiki/Unix_domain_socket

As soon as the child receives data through a TCP connection, the same data will be sent to the fathers process through the Socket Unix domain, and the last process will be immediately notified

+2
source share

All Articles