I am planning to use sockets (local TCP) to communicate between two processes (running locally). One process will act as a server, but both processes send messages to each other asynchronously. Should I keep the socket connection open for the lifetime of the processes, or re-connect for each request?
Are there any problems that may occur if I keep a local socket open?
Keep the socket open.
Its the simpler option and you don’t incur in the overhead of opening a new socket (from the client point of view) or accepting a new client (from server point of view).