Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know enough about the application, so it's possible this can be further simplified, but I would do the following:</p> <ul> <li><p>Create one or two server processes listening on known ports (you could probably get this down to one, but if you need two, ok I'll explain how to do that).</p></li> <li><p>If you can get it down to a single server process, it can listen on both ports itself. Using the <code>select</code> call, you can have it monitor for activity on each open file descriptor. In fact, this is why I think you could do the entire thing with a single process, or a small pool of them.</p></li> <li><p>Have the client connect to the known port on the server. Having the server connect to the client will give you trouble when you get into remote networks. You can always get the server somewhere with port forwarding or in a DMZ, but you can't insist that all of your clients change their network to remove NAT, disable firewalls, or forward ports for your application.</p></li> <li><p>When the client connects, if you need multiple processes, have the servers establish as open connection to each other before forking so that you can connect them using the known port.</p></li> <li><p>If you need a separate process, use <code>fork</code> to split the processes. In the child process, you close the file descriptors that are listening on the known ports. And in the parent process, you close the file descriptors that are connected to the clients in addition to the file descriptors that are connected to the other server process.</p></li> </ul> <p>Note: this is from a linux background, but I'm pretty sure all of these functions and methods will work on windows. I'm sure someone will correct me if I'm wrong. I strongly suggest trying to use <code>select</code> to get this down to a single process which will greatly simply your coding. If you need to make better use of a multi-processor system, then go multi-threaded or have a pool of processes that trade-off the connection handling. Learning about how file descriptors work after a <code>fork</code> will simplify your coding should you need to create multiple processes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload