Rectangle 27 4

You are telling AddFormField() to encode text values using UTF-8, and then the UTF-8 octets are being additionally encoded during transmission using MIME's quoted-printable encoding, which is the default setting for the TIdFormDataField.ContentTransfer property for text data. You are seeing the quoted-printable text in your PHP output. If you want PHP to receive raw UTF-8 octets instead, set the TIdFormDataField.ContentTransfer property to '8bit' or 'binary' instead, eg:

param.AddFormField('offer[fullname]',UserArray[0], 'utf-8').ContentTransfer := '8bit';

Otherwise, your PHP code will have to decode the quoted-printable data using the quoted-printable-decode() function.

well i know that your solution works, but i have certain problems with my delphi and my indy10.... it sends me error at .ContentTransfer So i have personal request to you. Can you compile my small project and give me link to download the exe file? this is the link to my project -

The ContentTransfer property was not available in the version of Indy (10.5.7) that shipped with Delphi XE. It is a fairly recent addition in 10.5.8, which is available in Indy's SVN.

I wast try to upgrade my Embarcadero RAD Studio XE 3 TIMES...and i cant do it.. Please can you do that i ask from you? Can you compile my project and send me link to download it?

@TreantBG: Instructions are on Indy's website. What exactly are you having trouble with? Giving you a precompiled executable (and no, I will not do that for you) would be pretty useless if you cannot recompile the program yourself afterwards when needed.

Delphi Indy Send POST data in Cyrillic - Stack Overflow

delphi post send indy
Rectangle 27 0

Use the socket property, it has lots of functions for receiving data, starting with "Read".

DataAsString := IDTCPClient1.IOHandler.ReadLn;

Answer edited as Remy suggested.

indy - Delphi XE2 IdTCPClient - How to receive data? - Stack Overflow

delphi indy
Rectangle 27 0

I cannot duplicate your problem with a simple test case. I'd guess, the problem is, you're not closing the connection on the sending side after the data has been sent, thus leaving the receiving side blocked waiting data as Ken's answer say.

delphi - Program freeze if the buffer allocated for TTCPClient.Receive...

delphi sockets
Rectangle 27 0

As you can see from the other answers there are a lot of Delphi libraries to simplify network programming. However, AFAIK they all provide a friendlier layer over the WinSock API (on Windows, over the standard socket API on other OSs) and thus are not able to do anything that the WinSock API isn't able to do. In particular they may or may not support raw socket access, but if the OS fails to send data over the socket the libraries will only return errors as well.

For more information about the limitations of raw sockets on most recent Windows OS versions see this MSDN page, in particular the section "Limitations on Raw Sockets". It states quite clearly that

To get around these issues, it may be required to write a Windows network protocol driver (device driver) for the specific network protocol.

Neither of the Delphi network programming libraries comes with its own network protocol driver AFAIK. And neither will help you with permission issues on limited user accounts, or the interference of the Windows Firewall.

As you mention WinPcap in your question you know it is capable of doing what you want. There are Delphi wrappers for it, like Magenta Systems Internet Packet Monitoring Components. However, as a C++ programmer you may be better off to use the library directly from C++, as Delphi adds nothing in regard to the socket programming you want to do. In particular you won't need the extra layer to hide platform differences that some of the Delphi libraries provide, as you will be programming directly against the libpcap API.

delphi - Does Indy support raw TCP sockets on Windows? - Stack Overflo...

delphi networking sockets indy
Rectangle 27 0

Your records contain non-ShortString strings in them, as evident by the fact that the number of bytes occupied by the character data is larger than the number of bytes being written into the stream - meaning that pointer values (2 x SizeOf(Pointer)) are being written to the stream instead of the actual characters. As such, you will have to serialize your strings manually, such as by sending the string length followed by the actual characters. And if you plan on supporting Delphi 2009+, you have to take Unicode into account, so you should encode the strings before transmitting them, and then decode them on the receiving end.

Records are useful for organizing your data in memory, but usually not very ueful for transmitting data over a network, unless the records contain only POD types (and a string does not qualify as that).

procedure WriteStrToIO(IO: TIdIOHandler; const S: String);
  Buf: TIdBytes;
  Len: Integer;
  Buf := ToBytes(S, IndyUTF8Encoding);
  Len := Length(Buf);
  if Len > 0 then IO.Write(Buf); 

  Len: Integer;
  Buf: TIdBytes; // or whatever you want to use...
  if Client.Connected then
    WriteStrToIO(Client.IOHandler, 'Adrian');

    Buf := ...; // secondary data
    Len := Length(Buf);
    if Len > 0 then

  NameStr: String; 
  Buf: TIdBytes;
  with AContext.Connection.IOHandler do
    NameStr := ReadString(ReadInteger, IndyUTF8Encoding); 

    // read secondary data ...
    ReadBytes(Buf, ReadInteger);

  // ShowMessage() is not thread-safe!
  Windows.MessageBox(0, PChar(NameStr), 'NameStr', MB_OK); 

As for the OnExecute event being triggered multiple times, that is normal behavior. That event is not tied to data transmissions at all. It is called in a continuous loop for the lifetime of the connection. Once you exit the event handler, it is triggered again immediately if the client is still connected. This is useful for message-based protocols like yours, where the event gets triggered, reads a single message waiting for data to arrive, exits, gets triggered again to read the next message waiting for data to arrive, and so on.

tcp - Delphi: (Indy) Send a header Record followed by a file - Stack O...

delphi tcp stream record indy
Rectangle 27 0

You are trying to serialize a variable of type TTypeInfo. Take a look at its declaration:

TTypeInfo = record
  Kind: TTypeKind;
  Name: ShortString;
 {TypeData: TTypeData}

Your code will serialize the first two fields, but will fail to serialize the hidden field that is part of the implementation detail. This is a rather special type. You cannot simply assign one TTypeInfo variable to another. You are meant to pass around PTypeInfo variables.

In fact, consider the code that sends the type information:

InvokeRec.ArgTypeInf := MethodArg.TypeInfo^;

This code is already broken because it is assigning to a TTypeInfo, which as I stated above cannot be done with simple assignment.

Now, you obviously cannot trivially serialize a PTypeInfo because that only has meaning in the address space of the process that owns it. And you cannot readily call GetTypeData() and serialize the PTypeData that is returned. That's a complex structure which also contains hard to serialize pointers.

I suspect the simplest approach will be to roll your own type information serialization mechanism. Perhaps it's enough to send the name of the type and then get the receiver to look it up using that name.

First of all, thank you for the reply ;] now second, while i debugged the client, it did send the TTypeInfo record completely (as i said, TTypeKind shows tkEnun (for Integer) and Name shows 'Integer'). and when i invoke method with a Boolean (which works too) it shows in Kind (TTypeInfo) 'tkEnumeration' and in Name it shows 'Boolean'. it's just that with string (Kind = tkUString) i have problems..

i don't know how to use that JSON, can i have example for my situation ? i never used it -.-".

It doesn't send the whole of the type data. Because the Delphi declaration lies about what's in the record. That commented out field indicates that there is in fact more information stored after the Name field. Since the compiler doesn't know about it, it cannot copy it. Take a look at the implementation of TypInfo.GetTypeData.

delphi - Exchanging data over sockets - Stack Overflow

delphi sockets winsock delphi-xe
Rectangle 27 0

Using TIdUDPClient the way you are, you are creating a static association between the remote pair and whatever random local IP/Port pair that TIdUDPClient binds to. Only packets sent from to that IP/Port can be received. The device needs to know where to send its packets to, and you need to receive them on the IP/Port that they are sent to. I don't recall offhand if TIdUDPClient has BoundIP and BoundPort properties in Indy 9, but it does in Indy 10.

ReceiveTimeout is expressed in milliseconds. Even if you have TIdUDPClient set up properly, 50ms is a very short amount of time to wait for data to arrive, so ReceiveBuffer() could simply be timing out. Try using a larger timeout value, at least a few seconds worth.

Alternatively, use TIdUDPServer instead. Set up its Bindings property with the local IP/Port pair(s) you want to receive data on, and then let its OnUDPRead event tell you whenever new data arrives from any remote IP/Port.

Unfortunatly Indy 9 doesnt have BoundIp and BoundPort properties...

Delphi Indy IdUdpClient read operation, No data returned - Stack Overf...

delphi delphi-7 indy udpclient indy-9
Rectangle 27 0

Are you looking for a socks proxy implementation? If not, then just start with a server (http would most likely be a good start) and build into it the ability to process your inbound XML data packet, and make the appropriate calls. Something like the Synapse framework would make that a fairly simple project. If you grab Synapse, get the latest version from SVN. It supports all of the latest versions of Delphi.

There is a httpproxy demo for synapse available, that might help if your wanting to implement something more traditional. A good starting http server example is also available.

Yes, I am looking for a straightforward TCP socket implementation. The broker will actually sit between BizTalk and an ERP system so I know 100% the data is XML, but not framed as a HTTP request. I do use Synapse under D2009 and will have a look at the HTTP proxy. Thanks.

Delphi transparent proxy for a TCP connection - Stack Overflow

delphi proxy tcp sockets
Rectangle 27 0

I suggest using UDP protocol and adding timestamp information to your data and track incoming data on the receiving end. You can use UDP server (TIdUDPServer) and client (TIdUDPClient) components from Indy or other packages. Client component is for sending data and server for receiving.

Personally I usually prefer Synapse -classes. They are lower level than Indy, so it's easier to know what's happening but on the otherhand you may need to implement something yourself what Indy may provide by default.

Drop TIdUDPClient on the form. Set "Host" to name or IP address of receiving end (or "localhost" if you run your programs in same computer) and port to high number where server is listening, eg 54656.

Add following code to button or timer event:

IdUDPClient1.Send('Hello, world!');

Drop TIdUDPServer component on the form. Set default port to same port as in sending application. Add OnUDPRead event handler, with code:

MessageDlg('Received: ' + StringOf(AData), mtInformation, [mbOk], 0);

UDP is not good for images, if you want to be sure they will stay uncorrupted, unless the image is very small and fits inside one packet.

For up to 100 clients or so, TCP is easier. UDP scales much better for a larger number of clients and also works well for discrete (short) messages that you can afford to lose.

@Misha I think it depends on what's the goal of application. If you're streaming online data and you're only interested on latest arrived data, in my opinion UDP is easier because you don't have to worry about connecting, disconnecting, delays etc.

@Harriv, yes, as long as each message is self-contained and fits neatly into a packet (as your update above explains).

indy - Sending and receiving data streams in Delphi - Stack Overflow

delphi indy
Rectangle 27 0

I'd recommend using anything but Indy. It is both buggy (especially versions bundled with Delphi) and slower than other component sets. It is easy to understand and start using it, but once you delve deeper under the hood, you start noticing small problems. Indy is constantly under development and you can find latest build here. Problem is that you can't easily replace the bundled version with newer in Delphi versions from 2009 onward because of some hard-coded dependencies.

Delphi has few other network communication methods integrated, but I recommend exploring 3rd party components. First, if you want open source, you should take a look at Overbyte ICS. It is a bit difficult to master, but it has good performance and feature set.

As a very good commercial solution, take a look at IP^Works. I have only scratched it, but from what I saw, I can wholeheartedly recommend it.

Rubbish! I have been using Indy in production since 2004. I have over 20 different applications (servers and clients) out there all communicating with Indy and I have never ever had a problem with the Indy components. Yes, if you take the latest build on a daily basis then there might be the odd issue, but these are quickly fixed. You can see how I built an entire generic communication framework from the download on my web site (

I have to correct myself since what I explained is related to protocol specific component issues, like IMAP. The TIdTCPServer and TIdTCPClient on the other hand are quite good, though I still claim that other component sets outperform Indy, especially in time-critical tasks.

Fair enough about the specific component sets (I don't really use anything outside of TCP, UDP, HTTP, and SMTP). Given that I can get delays in the order of milliseconds communicating with Indy and throughput of 20-50 Mbps for a connection, I suspect that any performance limitations are more in the implementation than Indy itself. As to how far you can push Indy, have a look at my question here -

@LightBulb: the "hard-coded dependancies" on Indy in Embarcadero packages were removed in XE/XE2 to make Indy upgrades easier on users without breaking anything.

@RemyLebeau-TeamB: I know that, but what about us who are stuck with older versions of Delphi, especially 2009/10? You can't expect us to upgrade Delphi just to be able to use a crucial component set. My point is that I need component set that works and it does exactly what is expected from it. That's why I'd still recommend against Indy if you need time-critical and long-lasting functionality.

indy - Sending and receiving data streams in Delphi - Stack Overflow

delphi indy
Rectangle 27 0

You have to use OLE Drag&Drop, but then you have to be able to process the data you receive, because each application can store data in its own format. You can find a nice Delphi implementation of OLE Drag&Drop here

Outlook Express and Thunderbird should transfer you data in RFC2822 format or something alike, Outlook will probably transfer data in its own message format, it shuould have been documented as part of the Microsoft Open Specification program

VCL! (Very Cool Link) A joke I just invented, probably duplicated, it is difficult to invent new jokes nowadays... Thanks a lot, the library seems to have all I need, there is an OutlookDemo example application. I will try and hope to be lucky.

I add one note: Office 64 bit is not supported, until we'll have the 64 bit compiler. Anyway it is not a big issue for now (january 2011).

email - How to implement Drag & Drop from outlook mail or thunderbird ...

delphi email drag-and-drop outlook thunderbird
Rectangle 27 0

You don't have to use Indy components, you just need anything that will handle communications over the network. Any HTTP or sockets network stack will do. Indy is the defacto standard for Delphi Win32.

To do network communications, you will need to create a listener object or service on machine A and a sender object on machine B to send a network message from A to B. To send a message from B to A, you will need a reverse path as well - 4 objects total to perform bidirectional comms. Some object wrappers hide this detail internally. I don't recall offhand whether Indy hides this or not.

It would probably be easiest if you use a common TCP/IP protocol for your machine to machine communications, such as HTTP. This will make it easier to get your connections through firewalls and proxies that frequently exist between arbitrary users. To avoid conflicting with any HTTP web services that might be running on either machine, you should use a custom port number with the IP address:, not the standard HTTP web server port 80. This is what most of the IM clients do.

indy - How can I transload data between two delphi applications over i...

delphi indy
Rectangle 27 0

TDataModule is not a descendant of TCustomForm, but rather of TComponent. So a data module does not have a window handle to receive messages, and has no handling for shortcuts like TCustomForm.

function TCustomForm.IsShortCut(var Message: TWMKey): Boolean;

  function DispatchShortCut(const Owner: TComponent) : Boolean;

delphi - Keyboard shortcuts not caught when Action Manager is in Data ...

delphi keyboard-shortcuts delphi-xe2 datamodule tactionmanager
Rectangle 27 0

Have you checked the Nagle settings of the IOHandler? We had a similar problem that we fixed by setting UseNagle to false. In our case sending and receiving large amounts of data in bursts was slow due to Nagle coalescing, so it's not quite the same as your situation.

delphi - Strange rare out-of-order data received using Indy - Stack Ov...

delphi delphi-2007 indy indy10
Rectangle 27 0

procedure TWebModule1.GetAllDataAsStream(ARequest: TWebRequest; AStream: TMemoryStream);
  BytesRead, ContentLength: Integer;
  Buffer: array[0..1023] of Byte;
  ContentLength := ARequest.ContentLength;
  while ContentLength > 0 do begin
    BytesRead := ARequest.ReadClient(Buffer[0], Min(ContentLength, SizeOf(Buffer)));
    if BytesRead < 1 then Break;
    AStream.WriteBuffer(Buffer[0], BytesRead);
    Dec(ContentLength, BytesRead);
  AStream.Position:= 0;

delphi - How to receive binary data from a request in TIdHTTPWebBroker...

delphi delphi-xe2 indy indy10 httpserver
Rectangle 27 0

Socket := AContext.Connection.Socket;
if not Socket.InputBufferIsEmpty then
  Socket.InputBuffer.ExtractToBytes(RawBytes, -1, False, -1);

  SetLength(Buffer, Length(RawBytes));
  Move(RawBytes[0], Buffer[1], Length(RawBytes));

  // Do stuff with data here...

It doesn't matter what IOHandler you grab, so the generic one seems like the go.

Sorry about answering my own question but it might be hepful for someone... maybe.

delphi - TIdTCPServer not reading data from socket sometimes - Stack O...

delphi delphi-2009 indy
Rectangle 27 0

TCP doesn't operate with messages. That is stream-based interface. Consequently don't expect that you will get a "message" on the receiver. Instead you read incoming data stream from the socket and parse it according to your high-level protocol.

Ok , How to handle received streams in the TCPClient using an external thread ?

@Kermia if you change the question radically, I suggest that you post a separate question.

How to handle received data in the TCPClient ? (Delphi - Indy) - Stack...

delphi indy
Rectangle 27 0

With JavaScript it is very common to access HTTP servers, for example over jQuery. If you can make your Delphi code available over HTTP, either as a local serveror on the web, your JavaScript code can invoke Delphi code by sending a HTTP request, and receive data from Delphi functions as a HTTP response.

Another option are WebSockets. They are an extension of HTTP, work asynchronously so the Delphi server can send data to the script - without having to wait for a request first (known as server push / Comet).

This would be a standards-based, widely used solution, which does not rely on a particular web client. The free open source library Internet Direct (Indy) can be used on all supported platforms to create HTTP servers, stand-alone or integrated with your application.

Other protocols which are availabe for communication between JavaScript and servers might be also worth a look, for example STOMP.

For your specific function, the HTTP call could use a GET request with parameters:


My Delphi code is NOT available over HTTP. I need a solution like comment of @Guillem Vicens but wrking on Android and iOS and I like use the new TWebBrowser on Delphi XE6. I think is TChromium is a bit complicated.

Callback Delphi function from TWebBrowser by javascript on Delphi XE6 ...

javascript android ios delphi
Rectangle 27 0

You can implement the logic you want. When you receive a push, it carries various data. If a notification is already displaying such data, you can cancel the existing notification and create a new one.

In any way, the notification manager of android will be able to stack notifications by itself for you.

So i suggest, when you receive data from a push:

  • Calculate the notification ID you need to display that notification (can be a hashCode of the notification type ?)
  • Fetch all notif for that type from sqlite
  • Cancel the notification with this ID (don't worry, cancelling a non existing notification won't make your app crash)
  • Create a shiny new notification with all the data you fetched, if you have more than one, you might want to display "+X other".

EDIT: With my answer, i assumed you can do as much as thing in "delphi to android" than in native android. Hence, i can't provide code for you, but the idea does not depend of the language you are using.

Thank you, your suggestions are very good. But, my problem is I am using delphi and I dont know how do could implement it in delphi object pascal language.

Ok, i can't help you for that, but i wish you good luck

Stacking push notifications in Delphi to Android application - Stack O...

android delphi push-notification
Rectangle 27 0

Your server code is calling IOHandler.ReadLn(), which expects a (CR)LF after the text. Your client is calling IOHandler.Write(), which does not send a (CR)LF. The client needs to call IOHandler.WriteLn() instead.

excellent. i used sLineBreak as per this q&a

sLineBreak is platform-dependant. It is a CRLF on Windows, but is a LF on other platforms. You really should not be using it for communications. Just use WriteLn() like I said: ` IOHandler.WriteLn(txtData.Text). It always sends a CRLF. If you insist on using Write(), then at least use Indy's own EOL` instead, which is a CRLF on all platforms: IOHandler.Write(txtData.Text+EOL)

i tired to run this project, server starting normally on port 801 ,but when the client connect button clicked it show this message : attempting to connect to ip [] and after 2 seconds cannot connect to ip [] , what can cause this ?

Is the server running on the same machine as the client? Did you verify with netstat or other tool that the server is actually listening on

delphi - IdTCPServerExecute runs but does not receive data - Stack Ove...

delphi indy