简体   繁体   中英

Java sockets java.io.EOFException

Getting Exception in thread "main" java.io.EOFException

at the last line of code, why? and how to fix... Thanks.

String ip = "XXX.XX.XX.XXX";
    int port = XXXXX;
    Socket socket = null;
    System.out.println("in function");
    socket = new Socket(ip, port);
    System.out.println("in function - After Socket");
    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
    System.out.println("in function - After ObjectOutputStream");
    ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());

The peer has already closed the socket. Possibly you sent it something it didn't understand. Unless it is a Java program that also uses object inout and output streams, it definitely won't understand.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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