简体   繁体   中英

Reset Socket input stream in Java

I am developing chat application in Java, allowing more users to connect to server. I managed to establish communication between clients, but the problem is when client sends message for the first time server recieves it and send it to destination client. But when the same client sends message for second time (and so on) server recieves message it receieved for the first time, so destination client is recieving the same message over and over again... I send object of type Message which I defined in another class..

I googled a little bit, and found out, that the problem is in stream and it should be reseted after each data had gone through stream. Output stream is possible to reset, but it doesent help. When I try to reset input stream I get an error. I runned out of ideas, has anybody got one?

It sounds like you need to call ObjectOutputStream.reset(). See the Jqvadoc for why.

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