Client/Server command line options

Samual Harvey

Ranch Hand

Posts: 119

posted 14 years ago

I was thinking to use the following options as command line for client and server. Please let me know if these are correct. client <hostname> <portnumber> server <database filename> <hostname> <portnumber> if the application is running in local mode then either the client will not have any commandline parameter. If the client uses localhost 1099 parameter then should I treat it as a local mode or remote? Another thing, I read somewhere on this forum that if both the client and server are running on one machine then it should be a local mode and not remote. Thus no remote objects will be created. Is this correct? Because I think if the server is started to run with a local machine name and a port number and then if the client also uses the same local machine name and same prot number then I think the client should be given the remote connection. Am I correct here? I think I should say whenever the client is run with a machine name and the port number it should always run in the remote mode but then how about when it uses the reserved word localhost and default port number 1099? Should this be local or remote? Thanks,

Samual Harvey<br />SCJP2<br />SCJD2

Michael Morris

Ranch Hand

Posts: 3451

posted 14 years ago

Hi Samual, The command line parameters are really up to you, since you know how everything works. Best I can tell, so long as you have a way of opening a db file in local mode, since you don't have a file parameter on the the client's command line, your command lines look fine. One other consideration may be to add a policy file, but once again only you know whether or not that is necessary.

If the client uses localhost 1099 parameter then should I treat it as a local mode or remote?

Absolutely remote. That's probably what the assesor is going to do to check your remote functionality.

Another thing, I read somewhere on this forum that if both the client and server are running on one machine then it should be a local mode and not remote. Thus no remote objects will be created. Is this correct? Because I think if the server is started to run with a local machine name and a port number and then if the client also uses the same local machine name and same prot number then I think the client should be given the remote connection. Am I correct here?

Did they say one machine or one virtual machine? If you start your server with its command line and then start the client with its command line for localhost:1099 on the same, let's call it desktop to avoid confusion, then it is no different from connecting to your server running on www.somewebsite.com:1099 as far as the creation of remote objects go. So in summation, you are correct.

I think I should say whenever the client is run with a machine name and the port number it should always run in the remote mode but then how about when it uses the reserved word localhost and default port number 1099? Should this be local or remote?

Once again remote. Hope this helps, Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher

Samual Harvey

Ranch Hand

Posts: 119

posted 14 years ago

Thanks for a wonderful reply. I have got a few more questions:- 1. How to input the databasefilename at command line. I mean should it be full path name like c:\\suncertify\\db\\db.db or something else? Should we also check if the file exists? 2. Should we create a GUI for the server? 3. How should be allow users to shutdown the server?

Thanks. [ August 26, 2002: Message edited by: Samual Harvey ]

Samual Harvey<br />SCJP2<br />SCJD2

Nate Johnson

Ranch Hand

Posts: 301

posted 14 years ago

Originally posted by Samual Harvey:

I have got a few more questions:- 1. How to input the databasefilename at command line. I mean should it be full path name like c:\\suncertify\\db\\db.db or something else? Should we also check if the file exists?

Full paths are the easiest... you should catch some sort of exception from your Data constructor when the db doesnt exist that you can then let the user know.

Originally posted by Samual Harvey: 2. Should we create a GUI for the server?

Not required... some do and some dont... I did not.

Originally posted by Samual Harvey: 3. How should be allow users to shutdown the server?

Thanks Nate. One more question:- I am having this strange problem. I am using createRegistry method of LocateRegistry. It works fine for all port numbers except for 1099. Do you know if this is a known problem? Should I check if the port number is 1099 then do not perform createregistry. Thanks.

Samual Harvey<br />SCJP2<br />SCJD2

Nate Johnson

Ranch Hand

Posts: 301

posted 14 years ago

Originally posted by Samual Harvey: I am having this strange problem. I am using createRegistry method of LocateRegistry. It works fine for all port numbers except for 1099. Do you know if this is a known problem? Should I check if the port number is 1099 then do not perform createregistry.

I had that problem when I was not using an ip address to rebind too... when I used a line like this I was fine...

1. How to input the databasefilename at command line. I mean should it be full path name like c:\\suncertify\\db\\db.db or something else? Should we also check if the file exists?

It really should not matter whether the path is fully qualified or relative. I would not mention something to the effect that full path names must be used on the command line in Readme.txt. Nate's right about handling a non-existant file.

3. How should be allow users to shutdown the server?

I did have a server GUI which had a shutdown button which was only enabled while the server was actually running. When the user pressed that button, I sent all subscribed clients a message informing them that the server would be going down in 60 seconds. When the 60 seconds expired, I locked the database, called unbind on the connection factory and sent a message to the clients that the server was down. You cetainly don't need to go to this much trouble, but if you want a simple controlled shutdown just lock the database exit. Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher

Samual Harvey

Ranch Hand

Posts: 119

posted 14 years ago

The hostname is keyed in by the user at the command line. What if the user keys in the machine name, lets say, "abc" and port number 1099. In that case the rebind will fail as I have createRegistry and my rebind is as follows:-

You are right if I use 127.0.0.1 alongwith createRegistry it works. So should I not use createRegistry when the port number is 1099 and hostname is not 127.0.0.1 Thanks. [ August 26, 2002: Message edited by: Samual Harvey ]

Samual Harvey<br />SCJP2<br />SCJD2

Nate Johnson

Ranch Hand

Posts: 301

posted 14 years ago

I used the line above no matter what because the server is always binding to the machine that it is on (localhost or 127.0.0.1), at least that is the way my design works... so it didnt matter if they put in 1099, which was also the default, the binding always worked... Did I even answer your question?

I am having this strange problem. I am using createRegistry method of LocateRegistry. It works fine for all port numbers except for 1099.

I used //localhost:1099/DBConnectionFactory (I actually built the string so the port value could vary) and never had any problem. Sometimes, while testing on Win98, if I restarted the server within a minute after exiting, then I would get a BindException. But then immediately starting againg everything worked fine. I never had a problem on Win2K. Who knows? Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher

Samual Harvey

Ranch Hand

Posts: 119

posted 14 years ago

OK. I was making the hostname as a command line parameter. I think you are right we should either use 127.0.0.1 or localhost. I think I should change mine to use one of these. Thanks.