3 ms·
Note that the stackoverflow post does not technically apply. accept() finds the smalles available file descriptor - it will never suddenly hand you a file descr
by noselasd 9y ago
Note that the stackoverflow post does not technically apply. accept() finds the smalles available file descriptor - it will never suddenly hand you a file descriptor of a huge integer value.
You can also control this with the "max open file" ulimit setting. This is by default often 1024 - meaning your process can have max 1024 open file descriptors, and the max value of a descriptor will be 1023.
Even if you need to support one or two orders of magnitude more file descriptors, a vector would likely be more efficient due to better memory locality.
- Const-me 9y ago> a vector would likely be more efficient due to better memory locality Vector’s memory locality only matters when you’re iterating over the elements. For this case it’s essentially a random index. Besides, unordered_map memory locality is fixable: https://github.com/Const-me/CollectionMicrobench https://github.com/Const-me/CollectionMicrobench
- matt42 9y agoI'll try and swith to unordered_map if it has a negligible impact on performances.