0
我正在嘗試構建java微博應用程序 我已完成代碼,但由於以下錯誤無法連接到我自己的計算機(我谷歌和有人說我需要更改,端口號,我改變了端口號和什麼都沒有發生)客戶機/服務器java應用程序中的JVM_Bind錯誤
Exception in thread "Thread-4" java.net.BindException: Address already in use: JVM_Bind
下面是該服務器的代碼:
public class server extends Thread {
public Socket client = null;
public ServerSocket server = null;
private int port = 4444;
public void run(){
while (true){ //loop waits for incomming connection
try { //start the server and listen to a port
server = new ServerSocket(port);
}catch (IOException e){
System.err.println(e);
System.exit(-1);
}
try { //establish a connection when receiving request
client = server.accept();
}catch (IOException e){
System.err.println(e);
System.exit(1);
}
Thread t = new Thread(new Connection(client));
t.start();
}
}
}
這是啓動服務器和偵聽端口代碼4444
Server server = new Server();
server.start(); //to listen to a port
謝謝
你試過了哪些端口? – thedayofcondor
4444.默認端口總是4444謝謝 – kaboom
也我試過7777和8888 – kaboom