Using J2SE, I tried making a LAN application using java.net.*, and it worked perfectly. I believe it's very similar (if not the same) concept to be a开发者_开发技巧pplied for online applications.
What package(s) or classes should I use to develop an online application? do I need a static IP address? Opinions, links and tutorials are welcomed.
Basically an application that works on the internet works exactly the same as one that works on a LAN. There are just a few points to keep in mind:
- Finding the other party of a connection might be harder. You can't really do any broadcasts, so you might need to have some central broker server to help different clients find each other
- Network performance is usually a lot weaker. This means both bandwidth and round-trip time. While on a LAN a ping of 1-2 ms is very easy to achieve, you'll get much worse values on the internet. Different applications have different requirements here, so some might not care about the round-trip times, while for others the bandwidth is not an issue
- Some computers might not have a public IP address at all, for example if they are NATed. This means that others can't connect to them. Usually they can connect to public IP addresses just fine, as long as they are the one initiating the connection (there are hacks that can help "connect" two non-public computers via UDP, but they are hard to do).
it's very similar (if not the same) concept to be applied for online applications.
In case of online applications conditions are lot much different, you have to bypass NAT and Firewall on both sides of peer.
I recommend you to go through JXTA.
精彩评论