Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

socket problem, plz help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my problem is

I have socket between server and a client
the client sending data to the server, so the server respond to the client with the response
this my code for receive the response data




look to the code, you can notice that I have 2 variables (nn) and (rr)
nn is the avialbe bytes in the InbutStream and
rr is the nubmer of byes did read from the InbutStream.

when i make a debug , nn = 8192 and rr = 22233 !!!


the question is HOW can I read _ALLl _ the received data from the InbutStream

waiting your help
 
author
Posts: 23924
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the question is HOW can I read _ALLl _ the received data from the InbutStream



The available() method returns the number of bytes that can be read *without* blocking.

The read() method *blocks* until it reads enough to fill the array, or an EOF is encountered.


If you only want to read the available bytes, then you need to either... read a byte at a time, or read into a part of the array. See the inputstream javadoc for more information.

Henry
reply
    Bookmark Topic Watch Topic
  • New Topic