Roman
Roman

Reputation: 1447

Maximum socket descriptor value

What maximum value of socket descriptor, which I get using functions socket() and accept() on Linux and Windows?

Upvotes: 1

Views: 1976

Answers (2)

unwind
unwind

Reputation: 399703

In Windows, sockets are not "small integers" like they are in Linux, they are opaque "handles".

So there's even less value in knowing some kind of maximum, it might be the same as the maximum pointer on the platform, for instance.

See this documentation page for a bit more.

Upvotes: 2

Alnitak
Alnitak

Reputation: 339786

The maximum value will usually be the same as the number of file descriptors simultaneously opened by that process.

However it's not AFAIK defined that way in any standard.

A socket descriptor is an int, so the theoretical value is INT_MAX, but that would make calls like select somewhat hard to implement, hence why they're just sequentially allocated.

Upvotes: 1

Related Questions