Perhaps your Winsock is corrupt, try with another Windows. Regards,
SZ ----- Original Message ----- From: "Engi" <[EMAIL PROTECTED]> To: "'ICS support mailing'" <twsocket@elists.org> Sent: Tuesday, April 10, 2007 1:09 PM Subject: Re: [twsocket] Listen exception Hi, Any ideas ? It's a real problem for me . Thanks, Engi -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Engi Envoyé : vendredi 6 avril 2007 13:50 À : 'ICS support mailing' Objet : Re: [twsocket] Listen exception Exception at Listen() method -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Fastream Technologies Envoyé : vendredi 6 avril 2007 12:59 À : ICS support mailing Objet : Re: [twsocket] Listen exception At which line do you get the exception? ----- Original Message ----- From: "Engi" <[EMAIL PROTECTED]> To: "'ICS support mailing'" <twsocket@elists.org> Sent: Friday, April 06, 2007 1:11 PM Subject: Re: [twsocket] Listen exception I talked too quickly. I still have errors 10022 from time to time. Here is my code: It is correct ? void __fastcall TThreadWORK::Execute() { try { WSocketServerWORK = new TWSocketServer(NULL); WSocketServerWORK->Proto = "tcp"; WSocketServerWORK->Port = PortIP; WSocketServerWORK->Addr = AdrIP; WSocketServerWORK->LineMode = true; WSocketServerWORK->LineEnd = "\r\n"; WSocketServerWORK->LingerOnOff = wsLingerOn; LingerTimeout = 5000; WSocketServerWORK->ClientClass = __classid(TTcpSrvClientWork); WSocketServerWORK->Banner = ""; WSocketServerWORK->OnClientConnect = WSocketServerWORKClientConnect; WSocketServerWORK->OnClientDisconnect = WSocketServerWORKClientDisconnect; } catch(Sysutils::Exception &e) { if (WSocketServerWORK) delete WSocketServerWORK; WSocketServerWORK = NULL; Terminate(); return; } try { WSocketServerWORK->Listen(); } catch(Sysutils::Exception &e) { if (WSocketServerWORK) delete WSocketServerWORK; WSocketServerWORK = NULL; Terminate(); return; } while (!Terminated) { ... } WSocketServerWORK->ShutDown(0); delete WSocketServerWORK; } -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Engi Envoyé : mercredi 4 avril 2007 14:27 À : 'ICS support mailing' Objet : Re: [twsocket] Listen exception Francois, Thanks for this explanations. I moved all the lines from constructor to Execute() method and all is fine now. Engi -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Francois Piette Envoyé : mercredi 4 avril 2007 13:15 À : ICS support mailing Objet : Re: [twsocket] Listen exception > No, I create the instance in the thread constructor. Any constructor for TThread class is executed in the context of the creating [likely main] thread, not the [future] created thread ! The new thread context exists only at the very beginning of the Execute method. So you must create any event-driven message based component from the Execute method or their events will run in the creating [main] thread and cause lot's of trouble when you access the component from the context of the created thread. The execution context [thread context] has nothing to do with the fact that the executed code is part or not of the TThread class. It is only related if TThread.Execute is in the call stack. This is a frequent error for newbies in multithreading. > Must I create instance in Execute method Yes, you have. > or deplace listening method in constructor ? You must too, or in any function/procedure called directly or indirectly from the Execute method. That is you have the Execute method in the call stack. If you are unsure about the thread context a given function is run, you may call GetCurrentThreadID and compare with the value f the same function called at the very beginning of the Execute method. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) 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 -- 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 -- 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 -- 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