Finding a port associated with a file descriptor

This is a discussion on Finding a port associated with a file descriptor within the Networking/Device Communication forums, part of the General Programming Boards category; Hi all, I'm struggling to find information about how to map a file descriptor to port numbers. Something I'm working ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    88

    Finding a port associated with a file descriptor

    Hi all,

    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?

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    Quote Originally Posted by drrngrvy View Post
    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?
    There's no such thing. A port is a port, and an fd is an fd. An fd can be associated with a socket, which can be associated with a port, but the relationship is only indirect. Why do you think you need a "port?"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Send image (.jpg) file over serial port
    By aSpareName in forum Networking/Device Communication
    Replies: 2
    Last Post: 06-30-2009, 09:35 AM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  4. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21