Try disabling your thread sleeping (the thread that reads from the
StringList).  Does your stringlist get all the the requests? i.e. is
TWSocket receiving them and your code parsing and putting them in the list


-----Original Message-----
Behalf Of Markus Humm
Sent: 14 September 2006 21:54
To: ICS support mailing
Subject: [twsocket] complex problem, probably not ICS related


sorry, this will be just a tiny bit longer... ;-)

I'm currently building some large application where several parts will
act together. Two of them are connected via TCP and TWSocket. One is
client and one server (okay there is TWSocketServer, but since there's
always a 1:1 relation between them and I don't have time to learn [and
wikify] all ICS components right now...).

The client sends requests to the server and the server will send back
the replies in the same format. This format is as follows:

1 integer defining the length of my packet
1 integer some ID I need
x byte the other needed data, can be any size but mostly < 100 bytes
1 word CRC so that it doesn't get too easy to spoof my connection.

The receiver puts incomming bytes into a ringbuffer with a greater size
than the buffer where TWSocket.receive puts the data in in the first
place. Then it checks whether there are packets of my format in the
ringpuffer and as long as there is one, one is fetched and given to a
callback in my application. There the syntax of the x byte is checked
and it is added to a TStringList. Reading and writing to the TStringList
is protected by the same critical section.

On the other side of the TStringList is a thread which will fetach one
entry and process it (will take around 50ms), but requests can come in
as fast as possible, thus this TStringList. If no requests are left in
the TStringList the threads gets sleepy (GetMessage) until something is
put into the TStringList again, which also will inform the Thread via

Replies generated from processing will be in the same packet format and
will be stored in another TStringList where another thread will fetch
one after one and send them back to the requester via the same TWSocket.
For the reply TStringList another critical section is used to protect it.

I have now a simple test client where I can send packets manually via
button or 1000 in one go via a for loop. The test app. displays the
replies in a memo. If I send some requests manually, all is fine, but if
I send them in the loop (no sleep between the iterations) the whole
thing gets stuck somewhere. At least no answers get back and it seems
that these requests are added to the request TStringList (I can see the
count of it) but something prevents further processing. This is a real
block for me now.

Now I want to rule out that it has something todo with the TWSocket and
or rinbuffer implementation. Do critical sections work in the same
thread or only for different threads?



To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to