简体   繁体   English

套接字系统EOFException(ObjectInputStream)

[英]Socket System EOFException (ObjectInputStream)

Hey i'm coding a socket system with a open src library... and everytime when i'm sending a message or something i get an EOFException 嘿,我正在用一个开放的src库对套接字系统进行编码...并且每当我发送消息或其他内容时,我都会收到EOFException

public Datapackage sendMessage(Datapackage message, int timeout) {
    try {
        Socket tempSocket;
        if (secureMode) {
            tempSocket = ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(address.getAddress(),
                    address.getPort());
        } else {
            tempSocket = new Socket();
            tempSocket.connect(address, timeout);
        }

        ObjectOutputStream tempOOS = new ObjectOutputStream(tempSocket.getOutputStream());
        message.sign(id, group);
        tempOOS.writeObject(message);

        ObjectInputStream tempOIS = new ObjectInputStream(tempSocket.getInputStream());
        Object raw = tempOIS.readObject();

        tempOOS.close();
        tempOIS.close();
        tempSocket.close();

        if (raw instanceof Datapackage) {
            return (Datapackage) raw;
        }
    } catch (Exception ex) {
        onLogError("[Client] Error while sending message:");
        ex.printStackTrace();
    }

    return null;
}

Please can anyone help me :c 请任何人可以帮助我:c

The peer has closed the connection without creating an ObjectOutputStream . 对等方已关闭连接,但未创建ObjectOutputStream Almost certainly it isn't using Serialization at all. 几乎可以肯定,它根本没有使用序列化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM