Jump to content

  • Log In with Google      Sign In   
  • Create Account


Detecting TCP/IP connections/disconnections


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 MauMan   Members   -  Reputation: 343

Like
Likes
Like

Posted 10 April 2000 - 12:16 PM

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

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 9565

Like
Likes
Like

Posted 10 April 2000 - 01:49 PM

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):

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++;
}
}


#3 MauMan   Members   -  Reputation: 343

Like
Likes
Like

Posted 10 April 2000 - 02:14 PM

I'm currently using a timer to recheck every so often but that seems to be overkill... :-(

Thanks for the response!


Edited by - mauMan on 4/10/00 8:16:08 PM




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS