> Markus Humm wrote: >> > Markus Humm wrote: >>>> >>> My application now has to tell the communication part (means the >>>> >>> server side of the TWSocket connection) to shut down. it sends him a >>>> >>> binary shutdown command and after a short time the client does a >>>> >>> shutdown(1) on the socket. >>> >> >>> >> There's most likely something wrong in your application logic. >>> >> When the server receives your custom shutdown command it should stop >>> >> listening first, send an OK-response back to the requesting client >>> >> and disconnect all client connections. >>> >> >>> >> On the client-side after sending your custom shutdown command, >>> >> receive the OK response and subsequently either Close the connection >>> >> actively or wait for the server to close the connection. However with >>> >> "wait" I do of course _not_ mean "wait in some loop", OnSessionClosed >>> >> fire on connection close. >>> >> >> > >> > That might be a option, but I'm not yet fully convinced. How long may >> > it take to send a short message to localhost and receive it on the >> > other side? > It depends. If blocking tasks are executed at that moment no window > messages can be processed and no data can be received. If server and > client are running in the same thread context one blocking task is > enough to block both client and server I/O. > >> > >> > I mean if a message loop of 3 sec. doesn't give him enough time > Possibly the message loop isn't implemented properly? > Please show us some code.
Ok, my message loop was constructed like this: var msg:TMessage; t:Dword; begin t:=GetTickCount; while (abs(GetTickCount-t) < 3000) do begin PeekMessage(msg, 0, 0, 0, pm_remove); TranslateMessage(msg); DispatchMessage(msg); sleep(20); end; end; One thing I'm currently not sure of (will check tomorrow) whether the sending application also had its own thread for the TWSocket. If yes, then the waiting was in the main thread instead of the secondary thread. The message processing of the secondary thread would have been implemented with GetMessage then (at least out of my head). I'll check tomorrow. Greetings Markus -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be