File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes socket problem, plz help Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "socket problem, plz help" Watch "socket problem, plz help" New topic
Author

socket problem, plz help

ezzat Al Hakeem
Greenhorn

Joined: Sep 06, 2006
Posts: 1
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
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16681
    
  19

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://jrebel.com/download
 
subject: socket problem, plz help
 
Similar Threads
Simple socket client listening to data from server.
InputStreamReader & reading bytes...
Sending file over network through sockets using serializable object
Problem while transferrinf file over network thru serializable object
polling a socket