I'm writing a application in D2006 and build a communication dll for it.
The communications dll encapsulates different communication methods (for USB, 
Ethernet communication is done via ICS TWSocket, the version included on the 
partner cd.

The DLL has a data module which has one single TWSocket for all incomming data
and for each outgoing connection a TWSocket is created dynamically. The 
instance of this 
socket is stored in a TObjectList together with other relevant information.
When the first connection is opened a seperate thread within the DLL is created 
for handling
of the windows messages (needed by TWSocket and other components as well).

This works so far until the point is reached where the DLL is freed.
The DLL is used statically in another DLL which has a thread for each 
connection too.
This 2nd dll is loaded dynamically. When it is freed via free library, its 
checks if there are any open connections thus threads) left. If yes, they all 
get freed
and by freeing them each connection in the first dll should get closed too.

With TWSocket this doesn't work, because socket.close seems to hang and the 1st 
DLL never 
reaches the statement after the close.

Pseudo code is like this:

- write a marker to the windows eventlog (debug output)
- call socket.close;
- sleep(25);
- write a marker to the windows eventlog (debug output)
- call socket.free;

The 2nd marker is never reached!!!
In my test app. it's as follows: a connection is opened, data is send and when 
closing the form,
freelibrary for the 2nd dll is called. It hangs the application for some time 
and a look in the
eventlog reveals that the 2nd marker never gets written. If you try to close 
the app. again after
halfe a minute itgets closed like nothing had hapened.

If one does the same thing (same test app.) but uses a RS232 connection instead 
of the UPD one 
via TWSocket it works well when you close the app.

What can this be? I think the bug was already in the dll back when I used D2005 
for development,
I don't think it's specific to the ICS version on the D2006 partner DVD.


Markus Humm
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to