TIdTCPServer no method to send binary data ?

I am writing a TCP server which will send binary data to a client on reception of a "SEND" command from the client.
The ServerExecute event code is shown below. I don't find any method in the Indy control to provide sending of binary data, only a Unicode String ? Hoe do I send binary data back to the client ?


void __fastcall TForm1::IdTCPServer1Execute(TIdContext *AContext)
{
      for(;;)
      {
            if(AContext->Binding->Readable(10))
            {
                  TByteDynArray b;
                  b.set_length(20);
                  try
                  {
                        int n;
                        n = AContext->Binding->Receive(b);
                        if(n>=4)
                        {
                              char *buff = new char[n];
                              BytesToRaw(b,buff,n);
                              if(strncmp(buff,"SEND",4)==0)
                              {  // request from client for data
                                    unsigned int *tx;
                                    tx = new unsigned int[6000];
                                    //  some code to initialise the tx data
                                    ///...

                                    // send the data
                                    AContext->Binding->??? // no method to send binary data, only unicode strings ?

                                    delete [] tx;
                              }
                                        else
                                        { // handle other commands from the client
                                       
                                        }
                              delete[] buff;
                        }
                  }
                  catch(Exception &e)
                  {

                  }

            }
    }
}
LVL 2
Roger AlcindorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
>>Hoe do I send binary data back to the client ?

Sorry for being so blunt, but: just like the rest of the interwebs do it - base64-encoded (http://en.wikipedia.org/wiki/Base64)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roger AlcindorAuthor Commented:
The code below is what I ended up using. If I understand you comment correctly, using Base64 encodes the binary data to text which would require decoding at the client end. The client end in this application is written using Indy 9 controls and an old BCB 5 compiler that does not support Base64 coding.

      n = 6000 * sizeof(unsigned int);
      b.set_length(n);
                    b = RawToBytes(tx,n);
      AContext->Connection->IOHandler->Write(b,n,0);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.