How to establish homebrew server connection
HOST
First, my host is dreamhost. I have root access. The system is a linux system.
SERVER
**UPDATE: It looks like the server uses modsecurity (modsecurity.org). I'll look into it more now, but if anyone has any tips or knows how to work with it, that's where I'm stuck now. **
Second, I wrote a java server that binds to port #### and the listens for connections. I can run this local & connect, but I'm trying to put it up on my server and con开发者_JS百科nect from anywhere. That is the idea behind a server.
private int port;
private ServerSocketChannel ssc;
private Selector selector;
public Server(int port) {
this.port = port;
}
public void run() {
try {
ssc = ServerSocketChannel.open();
selector = Selector.open();
ssc.socket().bind((new InetSocketAddress(port)));
new Thread(new ReadLoop(selector)).start();
new Thread(new AcceptingLoop(ssc, selector)).start();
System.out.println("Bound to port " + port + " and awake:");
} catch (IOException e) {
System.out.println("Server could not start.");
e.printStackTrace();
}
}
I launched this on the server. The program says it successfully bound to the port.
CLIENT
The client is flash, AS3. Here's the code i use to attempt the connect:
var mySocket:XMLSocket = new XMLSocket();
mySocket.connect("http://mydomain.net", ####);
I'm well aware of the sandbox policies. This is something else. I receive this error:
IOERROR [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2031: Socket Error. URL: http:--mydomain.net"] (replace -- with //, stackoverflow was reading it as a link)
This error apparently means that Flash never found a server. I would have gotten a security error if it had been the sandbox.
Anyway, how do I tell if ports are open correctly, if they are blocked, etc?
I'm also wondering if this has something to do with it: http://wiki.dreamhost.com/Mod_security
I unfortunately don't understand a lot of this stuff, but I'm trying to learn.
Try and run your server program on a port that is unlikely to be blocked (e.g. 80, 443). Of course, make sure that nothing else is using the port that you choose.
精彩评论