Re: [twsocket] Does a call to TWSocket.Send have to be on the same thread as the socket?
If I make a Send call to that socket, does it have to occur on the same thread as the worker thread? Or can I call it's Send method from another thread? I looked at the WSocket.pas code and I didn't see anything that looked like it wasn't thread-safe, Sending data pass thru the internal buffer which is protected by a critical section. So it should be thread safe. but I'm having some strange problems like missing OnDataAvailable() events so I wanted to check. This usually comes from bad handling of message pump. Check that part of your code. Also, don't call the message pump directly or indirectly from one of the component event ! -- 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] Does a call to TWSocket.Send have to be on thesame thread as the socket?
François Piette wrote: If I make a Send call to that socket, does it have to occur on the same thread as the worker thread? Or can I call it's Send method from another thread? I looked at the WSocket.pas code and I didn't see anything that looked like it wasn't thread-safe, Sending data pass thru the internal buffer which is protected by a critical section. So it should be thread safe. Looking at the source it is IMO not safe since bAllSent variable is not always protected by the critical section, this may lead to race conditions if you ask me. -- 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
[twsocket] TSslHTTPCli: POST with XML data to get RESOURCE on REST
Hi, I am working on an OAuth API. I achieved the following using TSslHTTPCli in combination with TSslContext: 1. Getting Token and Secret Token. 2. Getting Access Token and Access Secret Token. 3. Getting Account List. {REST resource HTTP Method GET} 4. Getting Account Balance. {REST resource HTTP Method GET} In all of my above example, I put the OAuth parameters in TSslHTTPCli.SendStream and it works fine. What I am not able to do is to get REST resource with HTTP Method POST. The documentation in the API is: HERE IS A LINK FOR API http://www.kgnsoft-in.com/oauth/api0001.gif SCREENSHOT FOR THE POST METHOD The problem is: I have OAuth parameters to pass the given URL with the above parameters. I am not sure how to this. What I tried: 1. I put the OAuth parameters in the URL and put the XML (with related values in an ANSIString) in TSslHTTPCli.SendStream The Response was ERORR: 400 2. I put OAuth parameters in TSslHTTP.SendStrean and added the XML string to Head in OnBeforeHeader event. The Response was ERROR: 400 3. I added these value as a field = value format and added to URL also put in TSslHTTPCli.SendStream The Response was 415 Unsupported Media ANY HELP WILL BE MUCH APPRICIATED. Thanks Iqbla Husain -- 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] TSslHTTPCli: POST with XML data to get RESOURCE on REST
HERE IS A LINK FOR API http://www.kgnsoft-in.com/oauth/api0001.gif SCREENSHOT FOR THE POST METHOD Please provide the link to the API you are trying to implement. Just that part is not enough. Have you seen this : http://tools.ietf.org/html/draft-ietf-oauth-v2-23 and this : http://tools.ietf.org/html/rfc5849 ? Which part of the standard is the problem ? -- 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 -Message d'origine- De : twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] De la part de Iqbal Husain Envoyé : dimanche 29 janvier 2012 17:00 À : ICS Overbyte Mailing List Objet : [twsocket] TSslHTTPCli: POST with XML data to get RESOURCE on REST Hi, I am working on an OAuth API. I achieved the following using TSslHTTPCli in combination with TSslContext: 1. Getting Token and Secret Token. 2. Getting Access Token and Access Secret Token. 3. Getting Account List. {REST resource HTTP Method GET} 4. Getting Account Balance. {REST resource HTTP Method GET} In all of my above example, I put the OAuth parameters in TSslHTTPCli.SendStream and it works fine. What I am not able to do is to get REST resource with HTTP Method POST. The documentation in the API is: HERE IS A LINK FOR API http://www.kgnsoft-in.com/oauth/api0001.gif SCREENSHOT FOR THE POST METHOD The problem is: I have OAuth parameters to pass the given URL with the above parameters. I am not sure how to this. What I tried: 1. I put the OAuth parameters in the URL and put the XML (with related values in an ANSIString) in TSslHTTPCli.SendStream The Response was ERORR: 400 2. I put OAuth parameters in TSslHTTP.SendStrean and added the XML string to Head in OnBeforeHeader event. The Response was ERROR: 400 3. I added these value as a field = value format and added to URL also put in TSslHTTPCli.SendStream The Response was 415 Unsupported Media ANY HELP WILL BE MUCH APPRICIATED. Thanks Iqbla Husain -- 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 -- 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] TSslHTTPCli: POST with XML data to get RESOURCE on REST
On 29-01-2012 16:00, Iqbal Husain wrote: 3. Getting Account List. {REST resource HTTP Method GET} 4. Getting Account Balance. {REST resource HTTP Method GET} In all of my above example, I put the OAuth parameters in TSslHTTPCli.SendStream and it works fine. How's that possible?! The GET method don't use the sendstream. With that methods you can only send the parameters in the URL itself, or in the request header. Take a look to this source code http://eden.fm/2011/02/27/twitter-library-for-delphi/ -- 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] TSslHTTPCli: POST with XML data to get RESOURCE on REST
On 29-01-2012 16:19, François Piette wrote: Please provide the link to the API you are trying to implement. Just that part is not enough. https://content.etrade.com/etrade/estation/pdf/API_Technical_Documentation.pdf -- 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
[twsocket] Help needed with TWSocket descendant with background thread message loop
I have a TWSocket descendant called TWSocketClientDeluxe. It does its work on a background thread. I have confirmed that this is the case by setting breakpoints on various events and inspecting the Threads window to make sure it is not on the main thread. It creates its own client thread and its Multithreaded property is TRUE. I recently changed my Send() method override to post buffers to the client thread so that the actual Send() takes place on the worker thread and not on the thread that calls TWSocketClientDeluxe.Send(). To facilitate this, the custom message loop I created to replace the base class method has custom windows messages for executing certain relevant requests and for processing the Send() data requests posted by TWSocketClientDeluxe.Send(). The client thread message loop then takes those buffers and calls a method I created called BgSend(). That method simply calls the base class Send() method (inherited Send()). I am having various problems so I am posting the code I wrote for the client thread's custom message loop to see if any of you see any problems with it. It's a little lengthy so my apologies in advance. The reason I have taken such extreme measures like moving to a background thread and decoupling the Send() operation is to avoid any thread blocking issues as much as I can. My application is the middleman between two sockets that cooperate in a multiple real-time audio streams. Therefore, I have to grab the buffer from one socket and send it out the other as quickly as possible. Hence the extreme measures. Note, the interface object retrieved from the MsgRec was already _AddRef'd an extra time before it was posted to make sure it did not destroy prematurely when recovered by the custom message loop. Here's the code, hopefully the formatting doesn't fall apart in your E-mail reader. Please comment on anything that is wrong or might cause instabilities or problems: -- Custom Message Loop For Socket Client Thread while GetMessage(MsgRec, 0, 0, 0) do begin TranslateMessage(MsgRec); // Is it a request to execute a custom background thread request? if MsgRec.message = WM_BG_CUSTOM_SOCKET_REQUEST then begin // ATI: 1-10-2012: Custom background thread request. // // If our owner socket is a TWSocketClientDeluxe instance and // we have a custom background request event handler, then // call it now. if WSocket is TWSocketClientDeluxe then begin theSockCliDeluxe := TWSocketClientDeluxe(WSocket); if Assigned(theSockCliDeluxe.OnBgCustomRequestProc) then theSockCliDeluxe.OnBgCustomRequestProc(MsgRec); end; // if WSocket is TWSocketClientDeluxe then end // Is it a request to reconnect with the same settings as the // last connect (current settings)? else if MsgRec.message = WM_BG_SOCKET_RECONNECT then begin // If we are not closed then this is an error. if not (WSocket.State = wsClosed) then raise Exception.Create('(TClientThread.Execute) A reconnect request was received when our socket was not in the closed state. Socket name: ' + WSocket.Name); // --- RECONNECT --- // Re-connect. WSocket.Connect; end // if (GAUNTLET) then else if MsgRec.message = WM_BG_SOCKET_SEND_REQUEST then begin // -- SEND DATA REQUEST -- // Recover the send data request interface. intf := nil; P := Pointer(MsgRec.lParam); if not Assigned(P) then raise Exception.Create('(TClientThread.Execute) Long parameter was not assigned, received pointer invalid while recovering the IPostBufferToCollection interface.'); Move(P, intf, sizeof(intf)); if not Assigned(intf) then raise Exception.Create('(TClientThread.Execute) Received an unassigned interface object.'); if not Supports(intf, IClientSocketSendDataRequest, intfCliSockSendDataReq) then raise Exception.Create('(TClientThread.Execute) Interface object received is not a IClientSocketSendDataRequest interface.'); if not Assigned(intfCliSockSendDataReq.data) then raise Exception.Create('(TClientThread.Execute) The send data request has an unassigned data pointer.'); if intfCliSockSendDataReq.dataLen = 0 then raise Exception.Create('(TClientThread.Execute) The send data request''s buffer length is less than or equal to 0.'); // Send the data now but use the background send method that // calls the inherited Send() method directly or we // will create a recursive self-posting situation. with WSocket as TWSocketClientDeluxe do BgSend(intfCliSockSendDataReq.data, intfCliSockSendDataReq.dataLen); // Release the interface variables we used.
[twsocket] TWSocket and Skype, anyone done that?
If anybody has used TWSocket to communicate with Skype when sending/receiving Skype audio via a port, please share any tips or problems that you had when doing so. Thanks, Robert -- 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