indy

How to track number of clients with Indy TIdTCPServer

依然范特西╮ 提交于 2019-11-30 15:55:30
问题 I want to know the number of current client connections to an Indy 9 TIdTCPServer (on Delphi 2007) I can't seem to find a property that gives this. I've tried incrementing/decrementing a counter on the server OnConnect/OnDisconnect events, but the number never seems to decrement when a client disconnects. Any suggestions? 回答1: The currently active clients are stored in the server's Threads property, which is a TThreadList . Simply lock the list, read its Count property, and then unlock the

How do I use TIdTelnet to send commands?

流过昼夜 提交于 2019-11-30 15:53:11
I am trying to simulate the "new identity" button in Vidalia (the Tor GUI) from my program. I asked about that , based on Rob Kennedy's answer, I tried this in my application: IdTelnet1.Host:='127.0.0.1'; IdTelnet1.Port:=9051; IdTelnet1.Connect(-1); IdTelnet1.SendCmd('SIGNAL NEWNYM'); But it has not worked for me. Even after I send the command, I get the same proxy. I am using Indy 9. I don't know whether I don't know how to use TIdTelnet or don't know how to send that specific command. You cannot use the SendCmd() method with TIdTelnet. TIdTelnet uses an internal reading thread that

How stop (cancel) a download using TIdHTTP

喜你入骨 提交于 2019-11-30 15:40:22
I'm using the TIdHTTP.Get procedure in a thread to download a file . My question is how I can stop (cancel) the download of the file? You could use the default procedure idhttp1.Disconnect... I would try to cancel it by throwing an silent exception using Abort method in the TIdHTTP.OnWork event. This event is fired for read/write operations, so it's fired also in your downloading progress. type TDownloadThread = class(TThread) private FIdHTTP: TIdHTTP; FCancel: boolean; procedure OnWorkHandler(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Integer); public constructor Create

How to track number of clients with Indy TIdTCPServer

无人久伴 提交于 2019-11-30 15:33:20
I want to know the number of current client connections to an Indy 9 TIdTCPServer (on Delphi 2007) I can't seem to find a property that gives this. I've tried incrementing/decrementing a counter on the server OnConnect/OnDisconnect events, but the number never seems to decrement when a client disconnects. Any suggestions? The currently active clients are stored in the server's Threads property, which is a TThreadList . Simply lock the list, read its Count property, and then unlock the list: procedure TForm1.Button1Click(Sender: TObject); var NumClients: Integer; begin with IdTCPServer1.Threads

Delphi TIdhttp Post JSON?

大兔子大兔子 提交于 2019-11-30 14:41:25
Anybody getting JSON to work with TIdHttp ? The PHP always return NULL in the $_POST , am I doing anything wrong ? Delphi source: http := TIdHttp.Create(nil); http.HandleRedirects := True; http.ReadTimeout := 5000; http.Request.ContentType := 'application/json'; jsonToSend := TStringStream.Create('{"name":"Peter Pan"}'); jsonToSend.Position := 0; Memo1.Lines.Text := http.Post('http://www.website.com/test.php', jsonToSend); jsonToSend.free; http.free; PHP source: <?php $value = json_decode($_POST); var_dump($value); ?> You can't use a TStringList to post JSON data. TIdHTTP.Post() will encode

How to login to a Gmail account and get number of messages in a mailbox with TIdIMAP4?

亡梦爱人 提交于 2019-11-30 13:25:45
问题 How can I login to a Gmail account and get number of messages in the INBOX mailbox with TIdIMAP4 component ? 回答1: To get the total number of messages in your Gmail's inbox, you need to, first connect to the Gmail IMAP server with your credentials, select Gmail's inbox mailbox and for that selected mailbox read the value of the TotalMsgs property. In code it may looks like follows (this code requires OpenSSL, so don't forget to put the libeay32.dll and ssleay32.dll libraries to a path visible

Delphi HTTP Post JSON

心不动则不痛 提交于 2019-11-30 12:42:55
I am sure I'm doing something wrong here. I've followed every example I can find on stackoverflow and still haven't gotten this to work in my environment. I'd love to update my controls and environment, but I'm currently locked in with what I have. I am using: Delphi 7 Indy 10.0.52 ulkJSON.pas v1.07 I need to send this JSON to a URL: "auth": { "applicationId": "appID", "applicationPassword": "pwd", "accountId": "acct", "userId": "dev" } There isn't anything terribly crazy about this, but when I try to post my request I tend to get a message that the request was Closed Gracefully.

Is there a way to set response timeout for Indy Tidhttp gets?

蓝咒 提交于 2019-11-30 12:40:01
I have built a simple website monitoring application using Indy TIdhttp component. I want to detect when a designated page is not returned within a specified time frame (I am using 5000 milliseconds). As a test I created a page on a web site which intentionally takes 15 seconds to respond. But I can't get my procedure to "give up" after the 5 seconds. I have tried ReadTimeout , a suggested solution using a timer and the OnWorkBegin event (was never able to get OnWorkBegin to fire immediately after the get call). Note I am not worried about a connection timeout. My concern here is a timeout for

Delphi 2009, Indy 10, TIdTCPServer.OnExecute, how to grab all the bytes in the InputBuffer

痞子三分冷 提交于 2019-11-30 11:41:30
问题 I am messing around with the Indy 10 supplied with Delphi 2009 and am having trouble with getting all the data from the IOHandler when OnExecute fires... procedure TFormMain.IdTCPServerExecute(AContext: TIdContext); var RxBufStr: UTF8String; RxBufSize: Integer; begin if AContext.Connection.IOHandler.Readable then begin RxBufSize := AContext.Connection.IOHandler.InputBuffer.Size; if RxBufSize > 0 then begin SetLength(RxBufStr, RxBufSize); AContext.Connection.IOHandler.ReadBytes(TBytes(RxBufStr

How to download a file over HTTPS using Indy 10 and OpenSSL?

ε祈祈猫儿з 提交于 2019-11-30 11:40:31
问题 I have the following task: download a file using HTTPS and authentication. Indy seems the way to go but for some reason it doesn't work so far. I have the following in place: a TIdHTTP component which I use for downloading a TIdURI component used to create the URL a TIdSSLIOHandlerSocketOpenSSL component which should provide the secure connection. The required DLLs are in the binary folder. The site also requires authentication and I included the user/pass in the URL as in the example below.