Reputation: 590
I wonder how system assign socket number in C. Is that random assignment or incrementally (first client has socket number 1, second client has socket number 2 , ...).
Upvotes: 1
Views: 88
Reputation: 70402
On UNIX systems, socket assignment is done like with other calls that return a new file descriptor. As long as the system has resources to create the socket, the lowest available file descriptor is used for the new socket. Otherwise, an error is returned instead.
Upvotes: 1