2013-05-16 103 views
0

我正在使用Netty編寫Java遊戲服務器。我可以成功地連接客戶端從本地主機,但我不能從遠程PC。在netstat util中不顯示監聽套接字。我在配置文件中錯過了什麼嗎?不顯示監聽套接字

@Override 
public void startServer(String host, int port) { 
    // Initialize server bootstrap 
    if (bootstrap == null) { 
     bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
       Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); 
     bootstrap.setPipelineFactory(channelPipelineFactory); 
     bootstrap.setOption("keepAlive", true); 
     bootstrap.setOption("tcpNoDelay", true); 
    } 

    // Unbind the port if bound 
    if (serverChannel != null && serverChannel.isBound()) { 
     serverChannel.unbind(); 
    } 
    serverChannel = bootstrap.bind(hostAddress); 
    ... 
} 
+0

'hostAddress'的值是什麼? –

+0

嘗試從遠程PC連接到服務器時收到了什麼錯誤? – Stephan

+0

你問你是否缺少你的conf。顯示conf。 – mstrewe

回答

1

嘗試綁定通配符地址0.0.0.0(或者:: :: for IPv6)。服務器將會監聽所有可用的接口。

+0

這並沒有解決問題..;( – OneMoreVladimir