Is socket creation-deletion very expensive process?
Asked Answered
G

1

9

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?

Galah answered 27/12, 2012 at 9:2 Comment(1)
You are probably reading an old book. Socket creation only requires memory for kernel socket data structures.Obstacle
G
11

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.

Gianina answered 27/12, 2012 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.