Thanks Gary. I was using readers and writers when the problem occured.
Thanks for the compacting tip...
Paul
Paul
On 5/19/06, Gary Jacobson <[EMAIL PROTECTED]> wrote:
Hi Paul
It may depend on the combination of streams/readers/writers you are using. If you are reading plain text from the socket, you should probably be using readers and writers rather than streams.
Incidentally, a more compact way to write your code is:
int x = 0;
ByteArrayOutputStream in = new ByteArrayOutputStream();while ((x=binput.read(b)) > 0) {
in.write(b,0,x);
}System.out.println("Read " + in.size() + " bytes from ITC");Cheers
Gary
On 5/19/06, Paul < [EMAIL PROTECTED]> wrote:
Hi
Clearly there is a right way to read a socket and a wrong way. If I
open a socket connection to a windows server to another windows server
and then read the input stream I am able to read all the data
correctly.
If I take the same code an run it on a linux server (reading the socket
on the windows server) then the code on the linux server seems to
receive less data from the windows socket. 2219 vs. 1368 bytes.
I have a sneaky suspicion that it has something to do with byte
encoding differences, but I'm not sure how to solve the problem, or
what the right way to read a remote socket is. Below is a sample of the
code used.
int x = 0;
ByteArrayOutputStream in = new ByteArrayOutputStream();
x=binput.read(b);
while (x > 0) {
in.write(b,0,x);
if (x==BUFFER_SIZE) {
x=binput.read (b);
} else {
x = 0;
}
}
System.out.println("Read " + in.size() + " bytes from ITC");
>>Output on windows:<<
Read 2219 bytes from ITC
>>Output on linux:<<
Read 1368 bytes from ITC
Do you guys know what the right way of doing this is?
Thanks,
Paul
--
Red Balloon Craft Junction
South Africa's premier online source of crafting information.
http://www.redballoon.co.za
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Tech" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Tech
-~----------~----~----~----~------~----~------~--~---
