Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Knowing with Network Interface will be used

Knowing with Network Interface will be used

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestiontutorial
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mmica
    wrote on last edited by
    #1

    Hi all, I am writing a system where a client communicates with a server and amongst other things tells the server what the client's IP and subnet mask are. However, when there are more than 1 network cards on a PC, how can I programmaticaly know which interface a packet is going to be sent on (for a particular destination)? I know how to get a list of interfaces and relevant details but don't know which one to use. Mark

    R 1 Reply Last reply
    0
    • M mmica

      Hi all, I am writing a system where a client communicates with a server and amongst other things tells the server what the client's IP and subnet mask are. However, when there are more than 1 network cards on a PC, how can I programmaticaly know which interface a packet is going to be sent on (for a particular destination)? I know how to get a list of interfaces and relevant details but don't know which one to use. Mark

      R Offline
      R Offline
      Roger Wright
      wrote on last edited by
      #2

      mmica wrote: I know how to get a list of interfaces and relevant details but don't know which one to use. The routing service on the PC will determine from the destination address which interface to use. If, for some reason, you need to select an interface in your app, though, the information stored in the routing table for the PC should be sufficient. Knowing the destination IP address and subnet mask, you should be able to compare it to the routing table in the machine to find which interface the address fits. If you AND the IP address of the host you want to reach with the subnet mask, the resulting network address should fit into one of the route specifications in the routing table. The illustrations here - The IP Routing Table - MSDN[^] - provide examples and an excellent explanation of how they're used. Will Build Nuclear Missile For Food - No Target Too Small

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups