5 Replies - 523 Views - Last Post: 18 November 2013 - 06:47 AM Rate Topic: -----

#1 Randor  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 147
  • Joined: 12-October 10

Re-accessing a server

Posted 14 November 2013 - 09:54 AM

Hello all,

I am playing with PBL's chat tutorial but I have run into a snag in how to re-access the server.
I want to be able to turn on the server, then close out the GUI, then reopen the GUI and have it check and see if the server is running, then give options to turn on/off depending...

so far im stuck trying to figure out how to check if there is a connection on the port that the server is running (I am assuming that you can access a port and check for a running server from that port)

can anyone point me in the right direction as to how to do this check?

Thank you

ps: the code for the PBL chat is here: Chat Server

I havn't really changed any of that yet

my feeble attempt to figure out how to connect to a port and see if there is a server on it is here:
import java.io.*;
import java.net.*;


public class Test {
    
    private static int port = 1500;
    
    public static void main(String[] arg) {
        
        try {
            
            ServerSocket serverSocket = new ServerSocket(port);
            
            if (serverSocket.isBound()) {
                System.out.println("Connected!");
            } else {
                System.out.println("Not Connected!");
            }
            
        
        } catch(Exception e) {}
    }
    
}


once again this is just and initial attempt to figure out how to connect

Thank you for any help..

Is This A Good Question/Topic? 0
  • +

Replies To: Re-accessing a server

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Re-accessing a server

Posted 14 November 2013 - 06:43 PM

Don't really understand what is your problem. Can you ellaborate ?
If the Socket is not monitored a connection/read should fail
There is also a Socket.setSoTimeout() method.. may be this is what you need
But again your problem is unclear
Was This Post Helpful? 0
  • +
  • -

#3 Randor  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 147
  • Joined: 12-October 10

Re: Re-accessing a server

Posted 15 November 2013 - 04:20 AM

Hi PBL,

Thank you for taking time to look.

I apologize for the lack of clarity. What I am looking to do is this:

I want to make a multi player game (I know, cliché right, lol) and so I need to have a chat/data server and put it on my host to manage the game. In your chat tutorial (which rocks btw) you built a GUI that can turn on and off the server, and when you close out the GUI it stops the server, well I want to be able to start the server then just let it run in the background continuously even after I close out the GUI. I know how to do that part, but what I am trying to figure out is how to re access the program after I close out the GUI. I want to be able to occasionally open up a new GUI and check in on the server, check the status of the server and whether it is still running, and be able to turn it off or on from the GUI I just opened.

I hope I have explained it better and I hope that it is even possible.

Randor
Was This Post Helpful? 0
  • +
  • -

#4 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1571
  • View blog
  • Posts: 3,529
  • Joined: 05-April 11

Re: Re-accessing a server

Posted 15 November 2013 - 08:48 AM

So you want to minimize the program to tray?
Or run the server as a service?
Or keep having the console open at all times, from where you can start the gui?
Was This Post Helpful? 1
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Re-accessing a server

Posted 15 November 2013 - 01:29 PM

As CasiOo mentionned it is not that easy.
The computer hosting the server can be in different location then your clients are (clients can even be spreaded worldwide).
To remotly start a Server you need a WebService on the Server host that can fired it (in Windows)
On OpenVMS a lot easier you can simply SUBMIT/REMOTE=HOST the command procedure that starts it :)
Was This Post Helpful? 1
  • +
  • -

#6 Randor  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 147
  • Joined: 12-October 10

Re: Re-accessing a server

Posted 18 November 2013 - 06:47 AM

Hi Guys,

Thank you.
I don't think I am explaining it properly, and for that I apologize.
I will try again if that is ok:

I want to write a multi player game, the plan is to put it on a hosted site (like www.netsol.com's shared hosting sites). I plan on writing an admin function to be able to start the game and to turn it off (as well as monitor it's status).
Unless I am not correct in my assumption (and I very well may not be), To start my game I would build a game server then build a GUI to access it from wherever (using a login of course). I would go to like www.mysite.com/gameAdmin.htm and embed the java admin into the html page. then from wherever I am I can go to the admin and log in and access the game server..

Now my question lies within the admin. obviously I can open the admin up and from in there start the game server, but this is where the problem lies.. the game server is now running but I want to restart my local computer that has the admin GUI open on it, now if I take out:
Mainwindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

then the game server still runs after I close out the GUI
so now I have the game server running but no GUI to access it,

So what I am looking for is any way I can re-open another admin GUI and have it look and see if there is a "copy" of the game server already running on the port, and if there is then is there a way to access it (stop it if I want to)? I don't want the game server to only run when I have an admin open, I want to be able to open up an admin to the game server, start it ( I would have the game server on like www.mysite.com:2000), then close the GUI (that I access through the same hosted website) and have the game server still run on the hosted site.

I hope I have cleared this up and I do apologize for not being clear enough on it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1