Hi to all. I'm programming a simple client/server application with the Berkeley API socket(), bind(), listen() and accept(). For now, i'm using a TCP connection to realize it.
The server process works with fork() to manage the different client connections, creating a child process for every connecting client.
Then, my problem is about the possibility for a child process to write on a socket that is not the socket open with "its" client. Let see an example:
Father process P.
Client A connects with P.
P forks and creates a child process 1 and opens socket 1A.
Client B connects with P.
P forks and creates a child process 2 and opens socket 2B.
Then, i would like to have process 1 writing on socket 2B.
The problem is that the socket descriptor returned by the accept() is always the same for every connecting client. I thought to store the socket descriptors and to use them for writing on the sockets from different processes, passing the current socket descriptonr as argument in write(). But this is impossible just because the accept() returns the same socket descriptor. How can i fix this?