java - How do I properly register clients on a server in RMI? -
i'm working on small project manages attendance summer program i'm helping run. rmi server run office , has specific port set using following code:
registry registry = locateregistry.createregistry(4051); remotemanager stub = (remotemanager) unicastremoteobject.exportobject(theserver, 4051); registry.rebind(server_name, stub);
where theserver
reference object serve system's server , server_name
static string
used represent server. shown registry binds server port 4051
clients can query it. i'm working on cross-communication between server , multiple client instances (12 teachers running same client program) , set such clients send stubs
of server client registration.
public void registerclient(interface_client teach) throws remoteexception { . . . }
where interface_client
extends remote
interface , client sent down calling:
server.registerclient((interface_client) unicastremoteobject.exportobject(this, 4052));
where chose port 4052
because didn't know doing. didn't bind stub registry. way it? because i've hardcoded client port, 12 teachers exporting object using port 4052 (at least that's how see it) respective client instances. should ports randomized? should not include port (there's method doesn't require well)? helpful hints appreciated.
as disclaimer, need reference client in server people in office can send messages teachers. (server -> client communication). client has reference server because can on registry.
any suggestion?
i chose port 4052 because didn't know doing.
that's ok, long port 4052 open in both directions in both intermediate firewalls, if there firewalls. there's no real reason why can't use rmi registry port 1099 this, @ both ends: it's reserved iana, unless hosts contain other rmi application.
i didn't bind stub registry. way it?
that's ok. don't need registry @ client. need existing registration api.
because i've hardcoded client port, 12 teachers exporting object using port 4052 (at least that's how see it) respective client instances.
that's ok long 'client instances' separate tcp hosts.
should ports randomized?
not unless have > 1 client per tcp host.
should not include port (there's method doesn't require well)?
no.
any helpful hints appreciated.
your clients must implement remote interface , exported , registered server via existing api. you're doing well. long there no firewalls, or under control, ok.
Comments
Post a Comment