Re: [twsocket] Send and Shutdown oddity
Markus Humm wrote: Hello, what does the event OnSentData _exactly_ signal? There does not exist such an event. There are two similar named events, OnDataSent and OnSendData. OnDataSent triggers after ALL data buffered in TWSocket's internal send buffer has been actually sent by winsock API send(). And there is OnSendData that triggers whenever data has been sent by winsock API send(). Whenever you call one of TWSocket's send-methods data is copied to TWSocket's send buffer first and the component the sends it asynchronously in the background. Does it really signal that WinSock has completed sending the data? No, see above. Winsock does not provide such a callback or event. -- Arno Garrels -- 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
Re: [twsocket] Send and Shutdown oddity
what does the event OnSentData _exactly_ signal? Well, there is no such event. You have OnDataSent and OnSendData which are close. OnDataSent: This is when Winsock has accepted all data from TWSocket, that is when TWSocket buffer is emptyed. OnSendData: This is when TWSocket is able to write data to winsock. Does it really signal that WinSock has completed sending the data? There is no such event available. And even if it is, then this doesn't mean anything since the remote side still has to acknowledge it. There could be an event for that, but as far as I know TCP stack doesn't propagate this to the application. I'd like to encourage those who already have a wiki account but never wrote anything in it to start helping to document ICS! +1 -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- 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
Re: [twsocket] Send and Shutdown oddity
Hello, either I have implemented the suggestion of confirming the reception of my shutdowncommand and only then closing the connection completely false or it's something quite curious and different: I found out now that the problem only happens under these conditions: - in my application's setup wizard there's the possibility to search for our Bluetooth devices and automatically pair and set them up. - when I close the wizard mentioned shutdowncommand has to be sent so that some part of my app. quits and is restarted afterwards. - only in the case when my app is running on a Laptop with Toshiba Bluetooth stack equipped and the device to be added to my application is not yet paired the shutdown command never arrives, no matter what I do. If the device has been paired previously everythign works like a charm! I've now contacted the developer of our Bluetooth library (named WCL) and hope he might shed some more light on this matter. I'm clueless now. 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
Re: [twsocket] Send and Shutdown oddity
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? I mean if a message loop of 3 sec. doesn't give him enough time why should the change of logic be better? Another related question: are there two logical channels in the background of TCP, one for sending the actual data and one for signalling the close? Otherwise I cannot explain myself why the data doesn't arrive but the close does. 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
Re: [twsocket] Send and Shutdown oddity
Another related question: are there two logical channels in the background of TCP, one for sending the actual data and one for signalling the close? Otherwise I cannot explain myself why the data doesn't arrive but the close does. There is only one channel. Actual data and signalling are using the same physical medium and are using the same packets. There are a number of headers in the packets which makes the distinction. -- francois.pie...@overbyte.be The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- 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
Re: [twsocket] Send and Shutdown oddity
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. why should the change of logic be better? Dunno, it's just how I would do it, following a simple request/response pattern. -- Arno Garrels -- 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
Re: [twsocket] Send and Shutdown oddity
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
Re: [twsocket] Send and Shutdown oddity
Markus Humm wrote: 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; That's most likely the cause, looks like an attempt to workaround the async nature of ICS. A message loop should use GetMessage and no Sleep(). -- Arno Garrels -- 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
Re: [twsocket] Send and Shutdown oddity
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. -- Arno Garrels -- 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