aspose file tools*
The moose likes Distributed Java and the fly likes do i have to supply a port number when start server? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "do i have to supply a port number when start server?" Watch "do i have to supply a port number when start server?" New topic
Author

do i have to supply a port number when start server?

xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
does RMI work with port?
because my server is working both with port number and without.
if RMI does work with port, then when the port number is not given, how does client know which port to connect to ?
thanks
X HOU

by the way, can someone recommend some good RMI books
Doug Melzer
Ranch Hand

Joined: Mar 23, 2000
Posts: 51
If no port is specified then the default port 1099 is used.
xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21

1099 is the default port of rmiregistry. if i export several server to rmiregistry, does it mean that all the servers listening port 1099?
i'm confused here about rmiregistry's port and the server's port.

X HOU
Kunal Aher
Greenhorn

Joined: Apr 07, 2000
Posts: 20
Hi ,
The registry's purpose is just to store and give you a reference to a remote service ( which many call server like chatserver , time server etc ). It listens on the specifed port and serves any requests for a particular service i.e a remote service .There is no question of ur server actually listening on that port.Aslo note that u cannot have 2 services running on the same port
(Correct me if I m wrong )


Kunal
xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
thanks for you reply. but i still don't understand:
if i start rmiregsitry on port 1099, and i export a chatserver to it, then what is the listening port of the chatserver?
if it is listening 1099, then that means the rmiregistry and the chatserver share a same port, and that's not allowed. (i think the rmiregistry is also a kind of server)
if it is not listening port 1099, since i didn't give it a special port, then how does the chatclient know which port to connect to?
and if i'm not allowed to export more than one server to a single rmiregistry, then does it mean i have to start one rmiregistry for each server i want to run, chatserver, mailserver, etc.
i'm confusing myself here. hopefully it doesn't confuse you.
X HOU

Kunal Aher
Greenhorn

Joined: Apr 07, 2000
Posts: 20
Your ChatServer neverlistens !! . Its the RMI Registry that is listening to some port for requests . When u bind an object to an registry u just make it available for ur other programs to be remotely accessible . I would advise u to refer to suns RMI Tutorial available at thier site .
Regards
Kunal
PS: Is ur Chatserver listening to some particular port ?? Will u let us know ur app briefly
xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
looks like i still thinking in socket when programming rmi
xiaoyi hou
Greenhorn

Joined: May 20, 2001
Posts: 21
i understand that server is never listening any ports now. but when i start coding a SSL RMI program, it's confusing again. here is a API copied from SUN's website:
public static Remote exportObject(Remote obj,
int port,
RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)
throws RemoteException
Export the remote object to make it available to receive incoming calls, using a transport specified by the given socket factory.
Parameters:
obj - the remote object to be exported
port - the port to export the object on // !!!
csf - the client-side socket factory for making calls to the remote object
ssf - the server-side socket factory for receiving remote calls
Throws:
RemoteException - if export fails
Since:
JDK1.2
what's this "port" for? it must not be 1099, that's the rmiregistry's port. so i give it a random port, but who's gonna use it anyway?

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: do i have to supply a port number when start server?