> So I called DetachThread before Attach Thread, but now I get the > exception that the socket cannot be detached.
You can detach a socket from a thread only when you call ThreadDetach within the same thread context which called TreadAttach (or the creating thread context if no attach has been done). See how ThreadDetach and ThreadAttach are implemented: they save and check thread ID. btw: Have you read my previous messages ? I'm still convinced you are confusing TThread class with thread execution context. -- [EMAIL PROTECTED] http://www.overbyte.be ----- Original Message ----- From: "Humm, Markus" <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Friday, February 03, 2006 10:15 AM Subject: [twsocket] closing socket socket > Hello, > > I tried something different now, but without success yet. > After looking at which thread ids where involved I got the following > results: > > - the socket is created in one thread > - the other thread is sending data over the socket, which works like a > charm > - the other thread then requests a close of the connection, so the > socket.shutdown > call is within the context of the other thread. > > Is this a problem? I do hope this is the reason for my problem. > Now I tried to attach the socket to the "new" thread just before calling > shutdown. > I got the exception then taht one cannot attach a socket which isn't > detached. > So I called DetachThread before Attach Thread, but now I get the > exception that the > socket cannot be detached. > > I have to possibilities now: > 1. find out why ThreadDetach doesn't work (I hiped you could shed light > on this) > 2. move the opening of the connection (thus the creation of the socket) > to the > execute method of the thread sending. Then creating, sending and > closing will be > within the same thread I assume. > > I'd like method 1. better because the communications dll could clean up > sockets in the > finalization section if the thread/programm using the dll didn't call > close_connection > properly. So it would be foolproof (nearly) I assume. > > 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 -- 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