IPC: Connect for each request or keep socket open?

大憨熊 提交于 2019-12-05 13:30:32

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).

If it's just one client, then you should keep the socket open but be ready to reconnect in case of error (the user could have reset network interfaces for example, so connection is not guaranteed to be alive). If you have many clients, use disconnection after inactivity timeout of certain time. This will let you get rid of inactive, hung or "lost" (the ones that passed away but there was no signal about socket closing form them) clients.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!