app.start(JmeContext.Type.Display) makes the program down

hi,I have two new problems now
can someone give advices to me? Thanks

the first problem is that when I call the ClientMain from the GameMain program(I use ClientM.main(xxx) inside the GameMain to call the ClientMain, is that right?), if the ClientMain is using app.start(JmeContext.Type.Display), the program will be down. When I change app.start(JmeContext.Type.Display) to app.start(), the problem is still there. When I change app.start(JmeContext.Type.Display) to app.start(JmeContext.Type.Headless), the program becomes normal, but I know this is not the proper way to do it…
So how can I run the ClientMain normally?

the second problem is that when I test the clientMain(which is using JmeContext.Type.Headless for start()), if I put “127.1.1.1” or “localhost” to be the host, the connection is successful. But if I put my external ip address(for example: 123.203.200.200), the connection is failed.Does anyone know what is the problem? How can I use that ip address to test my game?

here is the ClientMain I use:
[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.network.Client;
import com.jme3.network.Message;
import com.jme3.network.Network;
import com.jme3.network.serializing.Serializer;
import com.jme3.system.JmeContext;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ClientM extends SimpleApplication {

private Client client;
static ClientM app;

public static void main(String args[]) {
    app = new ClientM();
    app.start(JmeContext.Type.Display);
}

@Override
public void simpleInitApp() {
    try {
        client = Network.connectToServer("My Cool Game", 1, "localhost", 6143);
        client.start();
    } catch (IOException ex) {
        Logger.getLogger(ServerM.class.getName()).log(Level.SEVERE, null, ex);
    }
    Serializer.registerClass(GreetingMessage.class);
    client.addMessageListener(new ClientListener(),
            GreetingMessage.class);
    Message m = new GreetingMessage("Hi server, do you hear me?");
    client.send(m);


}

@Override
public void update() {
}

@Override
public void destroy() {
    client.close();
    super.destroy();
}

}
[/java]

  1. just call app.start() Not sure why you want to call the other.

  2. Not sure… though I have seen this before.

It looks like you might be basing your network code on one of the tutorials or something as I see some bad habits (catching the exception but not aborting for example) that I think are the way the tutorial is. You also start the connection before adding listeners, etc… If this is in the tutorial then the tutorial is wrong.

You might look instead at TestChatclient and TestChatServer in the JME test suite. They are better working examples.

Either way, instead of trying your external IP address try the local IP address (probably starts with 192). It could be that your router is preventing your from looping back through it like you are attempting.

<cite>@pspeed said:</cite> 1) just call app.start() Not sure why you want to call the other.
  1. Not sure… though I have seen this before.

It looks like you might be basing your network code on one of the tutorials or something as I see some bad habits (catching the exception but not aborting for example) that I think are the way the tutorial is. You also start the connection before adding listeners, etc… If this is in the tutorial then the tutorial is wrong.

You might look instead at TestChatclient and TestChatServer in the JME test suite. They are better working examples.

Either way, instead of trying your external IP address try the local IP address (probably starts with 192). It could be that your router is preventing your from looping back through it like you are attempting.

OK, I will try your advice.
Many Thanks for reply