Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is socket creation-deletion very expensive process?

I am working on a client/server application. I have ready many articles for this and found a very common statement that "Creation/deletion of socket is very expensive process in terms of using system resources". But no where it is explained how it is consumes so much resources.
Can anybody give glimpse view on this?

like image 923
Nipun Avatar asked Dec 27 '12 09:12

Nipun


1 Answers

Creating socket is cheap. Connecting it actually creates the connection, which is more or less as expensive as creating the underlying connection, specially TCP connection. TCP connection establish requires the three-way TCP handshake steps. Keeping connections live costs mainly memory and connections. Network connections are a resource limited by the operation systems (for example number of sockets on a port).

If you are using thread model additional thread creation resources needed.


I could find a useful like to your answer "Network Programming: to maintain sockets or not?" on Stackoverflow. And a useful article Boost socket performance on Linux

I think helpful to you.

like image 135
Grijesh Chauhan Avatar answered Oct 10 '22 04:10

Grijesh Chauhan