Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Checking if a network connection is available  (Read 1819 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Posted 2004-01-27 14:26:24 »

Hi there,

What is the best way to check if a network connection is available?
Right now I just try to connect and let it fail, and when it does fail it knows the connection is not available and continues in 'off-line mode'.
Problem with that is that my game is full screen openGL and when you're on dial-up, windows will pop up a dialog asking if you would like to dial in. This results in annoyingly getting back to windows in another resolultion where you have to answer the dialog after which it returns to full screen again.

Is there any other way to prevent this?

Erik

Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #1 - Posted 2004-01-27 15:31:52 »

This is not your problem.. it's a windows config problem.  In the internet options, there is a tab 'Connections', set the option:
Never dial a connection.

I had the same annoying behavior with a game that ewanted to register itself somewhere in the net..

One option to kwnow if you are in a network is to count how many IPs your computer has, if more than one.. (127.0.0.1) maybe you are online.. Just a idea...

 Rafael
Offline princec

JGO Kernel


Medals: 380
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2004-01-28 11:09:00 »

That's what I do - there's a util class in SPGL (CheckOnline or something) that looks for any IP address that isn't the local host. Works a treat. It doesn't actually check internet access, only network access.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2004-01-29 15:45:30 »

Cas,

Wouldn't that return true if you had a network adapter installed without DHCP even if it weren't connected to the net?

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline princec

JGO Kernel


Medals: 380
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2004-01-29 16:58:48 »

Yes, but it's the best you can do without actually attempting a connection. For 99% of systems out there the presence of a non-local IP address means a LAN or dialup is present.

Looks like a candidate API for the LWJGL; in Windows there's actual API to connect to the internet. Not sure about MacOS.

Cas Smiley

Offline Mark Thornton

Senior Member





« Reply #5 - Posted 2004-01-29 18:33:33 »

There is no one best answer to this question. It may be best to ask the user during install what type of connection they use and then adjust the strategy accordingly.
You can detect an active modem connection by enumerating the list of network interfaces and finding something that wasn't there before (or previously had a zero address). If the address is in a public range it is probably connected to the internet.
If there is a UPnP gateway on the local network you can detect that using UPnP queries (can be done in pure java), and then ask what IP is on the other side of the gateway.
People with on demand ISDN routers may get justifiably annoyed if you attempt connections without asking in areas with expensive charging structures.
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2004-01-30 19:47:13 »

I understand though that UPnP is seriosuly flawed  in terms of security...  I don't know the details thats just what I've heard.

Which is too bad because I have been saying for about 2 years whats needed for games is a standard way for them to negotiate with the firewall directly. **sigh**

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Mark Thornton

Senior Member





« Reply #7 - Posted 2004-01-31 07:08:51 »

UPnP may be flawed but it is out there and we can use it when available. Given that it can usually only be controlled from the inside, the only flaw I can see is that any opened ports remain open for a while after the aplication that opened them terminates.  Also if you do get infected by a virus then it can easily open any ports it wants and most people would never notice.
Offline Jeff

JGO Coder




Got any cats?


« Reply #8 - Posted 2004-01-31 16:58:43 »

Yes, but the "when its available" is indeed the key.  
based on security wranings from folks I trust I routinely disable it.  I don't know how many others do the same.




Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #9 - Posted 2004-02-02 16:16:22 »

Every time a WinXP box booted on my home network, it used uPnP to open holes through my router's firewall...

In my house at least, uPnP is culled wherever it is found. Grin

Hellomynameis Charlie Dobbie.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (103 views)
2014-09-10 06:39:09

Tekkerue (51 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!