Socket EADDRINUSE (Address already in use)

后端 未结 4 1661
野趣味
野趣味 2021-02-13 14:13

I am doing socket programming. I took reference from below link:

http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/

Below is deta

4条回答
  •  无人共我
    2021-02-13 14:29

    Try to create the instance of SocketServer outside of the run() method.

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState)   
        try {
            // create a new instance of an unbound socket first
            serverSocket = new ServerSocket(); 
            } catch (IOException e) {
               e.printStackTrace();
            }
    }
    

提交回复
热议问题