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