我正在开发一个客户端服务器套接字应用程序。在运行(覆盖)方法中为多个客户端读取服务器端的字符串,并在readUTF获取EOF异常。我不知道为什么会出现错误以及如何纠正错误。
while (ss.compareTo("true") == 0) {
System.out.println("Waiting for port " + port);
sdc = soc.accept();
cs[i] = sdc;
System.out.println("Connected port " + cs[i]);
DataInputStream dind = new DataInputStream(cs[i].getInputStream());
DataOutputStream dout = new DataOutputStream(cs[i].getOutputStream());
String password = dind.readUTF();
String dept = dind.readUTF();
uniqueName = dind.readUTF();
String username = dind.readUTF();
String ipaddress = dind.readUTF();
String macaddress = dind.readUTF();
String groupname = dind.readUTF();
}