Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How to detect connection?

This topic is 6489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to know how to detect a network connection(like icq), I try to use InternetGetConnectState() function, but when I try it on the PC connect to a LAN, even it did not connect to the Internet it return true. Is there any other method?

Share this post

Link to post
Share on other sites
There are several methods, i prefer to use the win32 api function:
this will return all active RAS connections. There are enough samples online that will demonstrate how to use it.

Another method is to ping a server on the internet, for example altavista.com .

Share this post

Link to post
Share on other sites
this gets really complicated:

I assume the goal is to detect a valid un-obstructed (not proxied or overly-restricted NAT) internet connection?

I can think of four cases:
Computer has no NICs, no modems
No connection possible
Computer has no NICs, at least one modem
RAS user, need to dial&connect to ISP then connect
Computer has at least one NIC, no modems
They either have a route out or they don''t, attempt connection
Computer has at least one NIC, at least one modem
Who knows. Try both

Generally you should just attempt to connect, and if the user needs to dial they either need to know to connect first, or have auto-connect enabled.

Share this post

Link to post
Share on other sites
Well, you could have them specify how they connect to the internet when installing, present them with a list of interfaces retrieved from the IP Helper API and add any RAS entries to the list also, then just check the state of whatever they select when your game starts.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!