elghazal-a
elghazal-a

Reputation: 590

How the system assign socket in C?

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

Answers (1)

jxh
jxh

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

Related Questions