B
bigbinc
I have a question and my own answer, but I think it is strange.
I am working with a server, and different clients.
One client is command-line, the other servlet(yea I said servlet, see
tunneling)
The commandline client works fine, but I have to modify my server(not
servlet) to fix the servlet client.
The problem? The servlet client reads in data twice(it is sent twice
or something?). I think it has something to do with the out.flush.
I can remove the newlines below and be ok. I just it is strange.
// server
out.writebytes(bytes);
//out.flush(); ?? remove comments fixes problem strangely
out.writebytes("\r\n\r\n");
out.flush();
// client
public String GetBytes(InputStream _instream) {
String _fin = "";
try {
byte [] tmp = new byte[2048];
int bytes;
int _debugbytes = -1;
while((bytes = _instream.read(tmp)) != -1) {
//_out.write(tmp, 0, bytes);
String _str = new String(tmp);
_fin += _str;
if (bytes > 0)
_debugbytes = bytes;
} // end of thw ehile
} catch(IOException e) {
} // end of the try - catch
return _fin;
} // end of the function
Berlin Brown
http://www.retroevolution.com
(e-mail address removed)
I am working with a server, and different clients.
One client is command-line, the other servlet(yea I said servlet, see
tunneling)
The commandline client works fine, but I have to modify my server(not
servlet) to fix the servlet client.
The problem? The servlet client reads in data twice(it is sent twice
or something?). I think it has something to do with the out.flush.
I can remove the newlines below and be ok. I just it is strange.
// server
out.writebytes(bytes);
//out.flush(); ?? remove comments fixes problem strangely
out.writebytes("\r\n\r\n");
out.flush();
// client
public String GetBytes(InputStream _instream) {
String _fin = "";
try {
byte [] tmp = new byte[2048];
int bytes;
int _debugbytes = -1;
while((bytes = _instream.read(tmp)) != -1) {
//_out.write(tmp, 0, bytes);
String _str = new String(tmp);
_fin += _str;
if (bytes > 0)
_debugbytes = bytes;
} // end of thw ehile
} catch(IOException e) {
} // end of the try - catch
return _fin;
} // end of the function
Berlin Brown
http://www.retroevolution.com
(e-mail address removed)