java - ObjectInputStream$BlockDataInputStream.peekByte when using program on internet -
i created application tcp, works nice when used on local network 127.0.0.1
server refused works when client try connect him network.
i don't know error means , how resolve , can't anderstand application works on lan.
public class reception { inputstream inobjet = null; bufferedreader instring = null; objectinputstream recvec2i = null; public reception(socket socket) { try { this.inobjet = socket.getinputstream(); this.instring = new bufferedreader(new inputstreamreader(socket.getinputstream())); this.recvec2i = new objectinputstream(inobjet); } catch (ioexception ex) { logger.getlogger(reception.class.getname()).log(level.severe, null, ex); } } public vecteur2i recevoir() { vecteur2i = new vecteur2i(); try { = (vecteur2i) recvec2i.readobject(); } catch (ioexception | classnotfoundexception ex) { logger.getlogger(reception.class.getname()).log(level.severe, null, ex); = new vecteur2i(1000, 1000); } return to; } public string recevoirstring() { string chaine = ""; try { chaine = instring.readline(); } catch (ioexception ex) { logger.getlogger(reception.class.getname()).log(level.severe, null, ex); } return chaine; } public void fermerreception() { try { instring.close(); } catch (ioexception ex) { logger.getlogger(reception.class.getname()).log(level.severe, null, ex); } try { inobjet.close(); } catch (ioexception ex) { logger.getlogger(emission.class.getname()).log(level.severe, null, ex); } try { recvec2i.close(); } catch (ioexception ex) { logger.getlogger(reception.class.getname()).log(level.severe, null, ex); } } }
and here exception :
avr. 22, 2015 9:33:33 pm snake.reception recevoir grave: null java.io.eofexception @ java.io.objectinputstream$blockdatainputstream.peekbyte(objectinputstream.java:2597) @ java.io.objectinputstream.readobject0(objectinputstream.java:1316) @ java.io.objectinputstream.readobject(objectinputstream.java:370) @ snake.reception.recevoir(reception.java:41) @ snake.partie.cycledejeu(partie.java:55)
regards,
you can't mix different types of stream via same socket when 1 or more of them buffered, , both bufferedinputstream
, objectinputstream
buffered. buffers 'steal' data each other. in case should i/o via object stream. has string-based methods.
Comments
Post a Comment