How to effectively keep the connection open on the client and server side?
TCP sends can send saved messages default if you activate SO_KEEPALIVE . But it might be a good idea to send your own save messages (to prevent disconnection of downtime in routers, etc.)
What happens when a client wants to notify the server that the synchronization process was successful, but at the same time, the server notifies the client of a new update ..?
Design your protocol so that it has a request identifier and may differ between notifications and responses.
Create your API as synchronous, but use asynchronous socket processing.
Is it possible to simply create a Tcpclient (client) and save this object in the whole program? And when some network operation failed, try reconnecting to this tcpclient object?
Are you sure it is possible to reconnect to the same client? IIRC is not possible with Socket , and the same applies to TcpClient
I would use the same client until it disconnected.
source share