title: Is it guaranteed that socket descriptors in linux/freebsd will have almost sequential or comparable numbers?
body: <p>I understand that there is nothing preventing linux to assign descriptors any random numbers in range 0...2^32 when I create new socket. <strong>But what reality is?</strong> In my application (web server) I need a mapping structure that maps descriptor into a "connection structure". I understand that some kind of RB-Tree (int -> connection_ptr*) will work, but linear array of connection_ptr pointers (where each pointer placed at offset (index) = descriptor value) would be a little faster.</p>