I'm struggling to find information about how to map a file descriptor to port numbers. Something I'm working on requires the program to 'accept()' connections from the file descriptor STDIN_FILENO, which is zero usually. The thing is, for a couple of reasons I'd like to use port numbers instead of file descriptors.
Converting from a port to file descriptor seems simple enough, but I can't seem to find an references to a platform-independent way to do a conversion the other way around. Does anyone have a link handy? Is this even a sensible thing to be doing?