Detecting TCP/IP connections/disconnections
I think the question I want to ask is:
Is there an API or technique that will notify a program
if the TCP/IP routing tables have changed?
Background:
I have a small program that runs in the background. One
of the things it does is show the current IP address(es)
for the machine the program is running on. I''d like to make
the list update if the user''s IP info changes (examples: dials onto the internet, disconnects from the internet, plugs in a PC Card/USB network card, changes the IP address of a network card under WIn2K, etc...).
Thanks.
---
See http://www.cyberbrinedreams.com
I don''t think there is an API that will set a callback or event for when a network interface receives a new IP address. Next best thing is to enumerate current IP addresses on the host and detect if new IP addresses are detected/old IP addresses aren''t listed.
From the MSDN Knowledge Base (Article ID: Q129315):
From the MSDN Knowledge Base (Article ID: Q129315):
void EnumIP() { char szHostname[100]; HOSTENT *pHostEnt; int nAdapter = 0; gethostname( szHostname, sizeof( szHostname )); pHostEnt = gethostbyname( szHostname ); while ( pHostEnt->h_addr_list[nAdapter] ) { // pHostEnt->h_addr_list[nAdapter] is the current address in host // order. nAdapter++; }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement