在尝试向客户端发送布尔型套接字连接时出现错误
我不明白发生了什么问题,所以如果有人可以帮助我找出发生了什么以及如何解决它
Caused by: java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
下面是服务器中的SendPacket方法
public class Game implements Runnable {
private Socket clientSocket;
DataOutputStream dataOutputStream = new
DataOutputStream(clientSocket.getOutputStream());
public Game(Socket clientSocket) throws IOException {
this.clientSocket = clientSocket;
}
public void sendPacket() throws IOException, InterruptedException {
dataOutputStream.writeBoolean(true);
dataOutputStream.flush();
dataOutputStream.close();
}
}
这是receivePacket方法
public static boolean receivingPacket() throws IOException {
DataInputStream dIn = new
DataInputStream(socket.getInputStream());
dIn.close();
return dIn.readBoolean();
}