如何从android连接到node.js服务器?

时间:2016-11-08 15:17:37

标签: android node.js socket.io

我使用以下代码通过socket.io与Node.js服务器通信,但我无法获得连接。

private Socket mSocket;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     try {
        mSocket = IO.socket("http://163.172.112.100:8443");
        Log.i("MainActivity: ", "Successfully connected!!!");
    } catch (Exception e) {
        e.printStackTrace();
        Log.i("MainActivity: ", e.toString());
    }

    mSocket.connect();
}

有谁能告诉我如何获得与服务器的连接或更好的android库socket.io?

0 个答案:

没有答案