Cannot retrieve all data from socket's inputstream on Mac OS 9
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Christian_Blumenroehr
Posted On:   Tuesday, October 1, 2002 07:49 AM

Hi, I have severe problems reading from a socket's inputstream on a Mac OS 9 with MRJ2.2.5 that uses jdk1.1.8. This is the scenario: From an applet I open a socket connection to a proxy server and send a HTTP request through the proxy to a webserver. The request is a GET to download a file. Now, everything works fine on PC and on MacOSX where I have a jdk>=1.3. The scenario also works fine on MacOS9 when there is no proxy in place. The strange thing is that I cannot retrieve all data being sent from the webserver when there is a proxy between the client and the server. But the proxy cannot be the root cause, since as I said it works on other platforms.    More>>

Hi,


I have severe problems reading from a socket's inputstream on a Mac OS 9
with MRJ2.2.5 that uses jdk1.1.8.


This is the scenario:

From an applet I open a socket connection to a proxy server and send
a HTTP request through the proxy to a webserver. The request is a GET
to download a file. Now, everything works fine on PC and on MacOSX where
I have a jdk>=1.3. The scenario also works fine on MacOS9 when there
is no proxy in place. The strange thing is that I cannot retrieve all
data being sent from the webserver when there is a proxy between the
client and the server. But the proxy cannot be the root cause, since as
I said it works on other platforms.


I use the following code to read the data from the socket:
contentLength is the response's contentLength as
specified in the header of the response;
input is the socket's inputstream.



			
int read = 0;
do {
chunk = readPayLoad();
process(chunk);
} while (chunk != null);

public byte[] readPayLoad() throws IOException {
int bufLength = 8 * 1024;
byte[] result = null;
if (read < contentLength) {
result = new byte[bufferSize];
int i = input.read(result);

if (i != bufferSize && i > 0) {
byte[] out = new byte;
System.arraycopy(result, 0, out, 0, i);
read += i;
return out;
}
else if (i != -1){
read += i;
return result;
}
else if (i == -1)
return null;
}
return result;
}




When running this on MacOS9 the method input.read(result) returns -1,
meaning that the EOF is reached, earlier than it is supposed to. I
already traced the data being sent from the proxy to the client and
verified that all data are in fact sent. However the jdk on the Mac
detects for some reason the EOF somewhere and when I repeat it,
I always can read another amount of data from the inputstream.


Does anybody have an idea how to fix that??


Christian

   <<Less
About | Sitemap | Contact