Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Java server?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 eqs   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 February 2000 - 04:04 AM

What would i have to do to implement a high score server for a game? My understanding is that the server class must be RUNNING as in in a window type running, on the actual servre. How do i make it run without opening it up in a window?? If that makes sence PLEASE reply. Its stopped me doing soo much and its such a stupid thing to get stuck on. PEAC GAZZ

Sponsor:

#2 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2000 - 02:45 AM

If you are running NT for your web server, then you will always need some sort of "window" open just to get to the command line(AFAIK, I don't do much with NT). Now that i think about it... i don't know how to get to a command line from Gnome or KDE either without opening up a terminal window. But other than that, you don't need to code any java.awt.Window or java.awt.Frame into your server application to get them to listen on ports. If your server allows you to run java apps, just telnet in and type the correct command.

Edited by - Jim_Ross on 2/11/00 8:46:53 AM

#3 eqs   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2000 - 05:46 AM

So your saying i can put the server.class whereever, and i telnet into it? I suppose that makes sence, but how would the client connect to it then?

PEACE
GAZZ

#4 Aldacron   GDNet+   -  Reputation: 3057

Like
Likes
Like

Posted 11 February 2000 - 04:02 PM

I think you need to read up more on client/server relationships

In a nutshell:

The server will be listening on a port on the computer it's running on. You specify which port with a number in the cofe (there are standard ports used for certain purposes, so you should avoid those). The client should be written to check the port number the server is listening to. If the server is up and running when the client probes the port, the communication process begins.

If memory serves correctly, there was an article at
http://www.javacoffeebreak.com that explains java client/server stuff. Also, if you want to run the server from your personal page, you need to check with your host to make sure you have permission to run programs in your space. If you're using Yahoo/Geocities or Xoom or some such, then you probably don't.

Edited by - Aldacron on 2/11/00 10:03:11 PM

Edited by - Aldacron on 2/11/00 10:03:58 PM

#5 Alaspin   Members   -  Reputation: 122

Like
Likes
Like

Posted 13 February 2000 - 09:02 PM

Check out the possibilities that Java RMI provide.


#6 eqs   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 February 2000 - 07:00 AM

Aldacron:
So all i have to do, assuming im allowed programs on the web server. Is upload the server file? Then my prog will automattically be listening to the port?
Also, is it best to hardcode the URL? Or to make it with respect to the codebase?


Thanks for your help guys.

PEACE
GAZZ

#7 Aldacron   GDNet+   -  Reputation: 3057

Like
Likes
Like

Posted 14 February 2000 - 01:40 PM

Really, you need to research this. Coding a server in Java is a cakewalk compared to C/C++, but it''s not something you can learn from a message board

To answer your question, you''re program will not automatically do anything! You need to start it first When the server is running it will listen to the port. That''s what a server does. A basic java server that does nothing would consist of 3 (at least 2) classes. The main function will be in MyServer. Of the other 2, one we''ll call MyPortListener, the other we''ll call MyConnection. (You could also put main in the MyPortListener if you wanted).

The program flow would be something like this:

In main you create a new MyPortListener. MyPortListener should implement Runnable (or extend Thread). When MyPortListener''s thread is started, it listens to the specified port. If a client requests a connection, MyPortListener creates a new MyConnection and then continues listening.

Now, obviously there would be more to it than that. Each connection would need to be handled in a seperate thread and you woul;d want classes to manage the flow of information between the server and each connection, but the outline above is the core of every server on the web. Listening to ports and creating connections.

And, yes, the port should be hardcoded into the source. It''s up to you which port number you use (as long as it''s not one of the standardized ports) and makes need not change even if the domain does. As far as the clients go, the actual URL to connect to should not be hardcoded (in most cases). It''s better to give the user an option. All depends on what you use it for. The port should be hardcoded in the client, but again, depends on what you use it for.

For a high-score server like you want, I would hardcode everything, including the URL. However, if you want to allow other people to run your high score server, hardcode the port in the server AND the client and let the user choose the URL.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS