• Post Reply Bookmark Topic Watch Topic
  • New Topic

when does a read method return -1 in a socket  RSS feed

 
vijay kolli
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I opened a datainputstream on a client socket. and the server is sending data periodically.

I am reading the data using this call: datainputstream.read(byte[])... so when would this return -1? I know that read method would return -1 when reading from a file and it is the end of the file.
 
Rob Spoor
Sheriff
Posts: 21117
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the socket connection is closed. That's the only time you can guarantee that no more data will come.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!