Link to home
Start Free TrialLog in
Avatar of Roger Alcindor
Roger Alcindor

asked on

How to set a TIdBytes variable in Borland C++ Builder 2007

I am porting an application from BCB 5 with Indy 9 to Borland C++ Builder 2007 using Indy 10
The Indy 9 SendBuffer function for a UDP server has two parameters for the data to send; being a char * and a length specifier.

Indy 10 makes it more complicated by introducing a single parameter of type TIdBytes which passes the same information.
The question is, how to generate a TIdBytes variable from a char * and length ? A function such as

TIdBytes MakeTIdBytes(char *data,int length); is required

The only way I can see to do this is something like the following which is a bit arcane if you want to send
a packet of a few hundres bytes :-


TIdBytes MakeTIdBytes(char *data,int length)
{
TIdBytes r;

    for(int i=0;i<length;i++)
    {
         r[i] = data[i];
    }
    return r;
}
ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Roger Alcindor
Roger Alcindor

ASKER

Thanks, that is the solution that I needed.