c - Retrieving local IP before a connection is made -


i trying determine local ip used on socket tcp connection towards given host on linux, using c.

let me make example. connect socket , use getsockname() on file descriptor local ip (and local tcp port); can without opening connection?

i read routing table , make decision based on - networking subsystem must have algorithm already, when connection open. in short, i'd know if there api access routing algorithms without having parse rules myself or opening actual connection. solution - if - linux that's ok.

edit: on irc suggested create udp socket , use connect() on it. no network used @ point should able use getsockname() on it

the solution know traceroute does. send packet ttl of 1 , see interface icmp return comes in on. recall there lots of incompatibilities between different hosts, there's several different types of messages might need send/receive data need.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -