Hello Markus,

Just free the socket. It will self close when it is connected.

Your code will work of course. When connected it will exit the loop
immediatly because OnSessionClose is called from within the Close
method, and when not connected it will time out. But it is not needed.

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Wednesday, April 26, 2006, 17:48, Humm, Markus wrote:

> Hello,

> I've got the following problem and look for the real cause:
> (don't know yet whether TWSocket is involved or not, but looks like)

> I've a dll with a message pumping thread and at least one sending 
> TWSocket and one seperate receiving TWSocket.

> The very same DLL provides also other communication ports (e.g. RS232).
> I've written several test programs now, two of the tree work fine, the
> third now crashes when closing it, but only when the UDP-Sockets 
> communication method is tested for e.g. RS232 it works fine.

> The other two test app.s are one which loads the dll via load library,
> the other one statically (external...) and is DUnit based. They both work 
> fine.

> The crashing test program uses one thread per connection (mostly not necessary
> for TWSocket but since paralellization is wanted and to be tested I 
> implemented
> it this way) and a seperate thread which queries the others to build some 
> statistic
> figures and display them via Synchronize on the screen. It uses the DLL 
> statically.

> When the program ends, all connections are closed and the DLL has a procedure 
> for
> shutdown which closes the message pumping thread and all open connections if
> necessary.

> Now the question: how are TWSockets closed properly? I've derrived a class 
> from them
> and overridden OnSessionClosed so that a flag is set when it occured.
> When closing the socket I call now this:

> socket.close;
> run a loop until either this flag is set or a timeout coccurs.
> socket.free;

> Is this the correct way? And how long to wait?
> The message pumping thread is closed after closing all sessions.

> Greetings

> Markus

-- 
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