I have a network of 16 computers all linked to the same switch, not connected to the internet. One of the 16 computers has a small Java app running on it开发者_运维知识库 along with a BlazeDS server (aka it's listening on a port for a message).
Currently, the other 15 "client" computers have to manually enter the "server" IP where the java app resides. My client app is Adobe Air, so I have no abilities there as far as scanning for the server.
I was thinking of writing a helper app / utility in Java or C++. At the very least, this app could display the IP to the user who could then input it into the Air app; sloppy but better than nothing.
I'm sure there are some tools out there that deal with this type of problem. Any ideas?
I would strongly recommend using Zeroconf/Bonjour for this as it makes it trivially easy to handle decentralized "where is the others who I should know about and should know about me"?
The easiest way to do this in Java (and completely inside your own application) is with the jmdns project. http://jmdns.sourceforge.net/
You could code a "discover" feature for the users that sends a heartbeat or test message to all the IP addresses in the same subnet of the current computer looking for the server that accepts / responds appropriately.
In a word, nmap. You can tell it to scan a netblock
$ nmap -P0 10.104.244.200
Starting Nmap 4.20 ( http://insecure.org ) at 2010-02-19 18:02 Eastern Standard Time
Interesting ports on BOSA638992.fmrco.com (10.104.244.200):
Not shown: 1688 closed ports
PORT STATE SERVICE
25/tcp open smtp
80/tcp open http
135/tcp open msrpc
139/tcp open netbios-ssn
371/tcp open clearcase
443/tcp open https
445/tcp open microsoft-ds
2030/tcp open device2
3389/tcp open ms-term-serv
MAC Address: 00:17:A4:F3:6D:A7 (Global Data Services)
Nmap finished: 1 IP address (1 host up) scanned in 1.750 seconds
See http://nmap.org/
Adobe AIR 2.0 (available as Beta) has the ability to communicate with native processes. See http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html
You can use this facility to call a helper that you write and ship with your app. This helper would use some means of discovering your server. For instance zeroConf Networking (called Bonjour by Apple). Your AIR app would than use the address it received from the helper to make a connection to the server.
multicast would work - how about http://www.jgroups.org if you are happy with java
精彩评论