🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #8598

Very strange and complex problem,

#8598
From: Edwin Günthner
Date: Sun, 11 Mar 2001 10:21
75 lines
3505 bytes
Hi folks,

we have a very strange problem and I think
it is a very interesting one and that discussing
it here might be quite productive. OK, lets start:

We are writing a GUI client that needs to communicate
with a C++ server (we are using TCP connections 
for this purpose). The communication works in two ways:

1 Server says: i will send you now 100 K of data
  Fine; my program reads the exact amount of bytes.
  Works fine every time.

2 Server says: i am going to send you data from
  the DB; dont know how much.
  Then the server will start to send packages with 
  a header, that tells me how long each individual package
  is. The idea behind that is that I ALWAYS know how much
  bytes I have to expect from the server.

We use technique no. 2 for sending the rows of DB
tables. Because we are splitting the data into blocks
of 5 rows or so we are able to start displaying the
first rows before all the rows have been send.

(I am using a special TableModel that uses invokeAndWait
to notify the table listeners).

OK, now its time to talk about our problem: 
sometimes we dont receive proper data. I dont have
an IOException or any kind of visible communication
problem; it is just that my InputStream gives
me bytes that should not be there!

For example, our server would send data like:

"a string"; 2424;"another string";;; 
"a string"; 2424;"another string";;;
"a string"; 2424;"another string";;; 
"a string"; 2424;"another string";;; 
"a string"; 2424;"another string";;; 

Most of the time that is exactly what pops up in my
InputStream. 

But sometimes (with JDK 1.3 SUN - and ALWAYS with 
JDK 1.3 IBM) the InputStream gives me data like:
 
??? ???? "a string"; 2424;"another string";;; 
"a string"; 2424;"another string";;;
"a string"; 2424;"another string";;; 
"a string"; 2424;"another string";;; 
"a string"; 2424;"another 

Where ? are ASCII chars like 0x0, 0x2, 0xA, etc (no 
pattern could be recognized). 

We are 99% sure that the C++ server sends 
correct data - but I have no clue how it is possible
to receive bytes from a socket based InputStream 
that have NOT been inserted on the other side.

I assume that it is some kind of threading problem:
in JDK 1.3 IBM the first errors happen when the table
should display a scrollbare and start scrolling. 

I think I need to use SwingUtilities.invokeAndWait() for
notifying the table that rows have been added - when
I used invokeLater the table will display the first rows
after the last rows have been received. Maybe invokeAndWait
needs to much time - but why on earth can this effect
my InputStream?

Any idea?
Technical Details
Message-ID: <3AAB51A7.1EBEF470@web.de>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.xtra.co.nz!newsfeed01.tsnz.net!bornews.borland.com!dnews!62.54.34.5

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,d415f4485eecbf26,start
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2001-03-11 02:34:04 PST
Message-ID: <3AAB51A7.1EBEF470@web.de>
Date: Sun, 11 Mar 2001 11:21:27 +0100
From: Edwin Günthner <edgue@web.de>
X-Mailer: Mozilla 4.76 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language
Subject: Very strange and complex problem,
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 62.54.34.5
X-Trace: 11 Mar 2001 02:18:48 -0800, 62.54.34.5
Lines: 75
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!arclight.uoregon.edu!enews.sgi.com!news.xtra.co.nz!newsfeed01.tsnz.net!bornews.borland.com!dnews!62.54.34.5