Mega Search
23.2 Million


Sign Up

Make a donation  
Indy 9 : UDP Client help?  
News Group: borland.public.cppbuilder.internet.socket

I created a nice, simple UDP application using the TUDP component included 
with BCB at one time.  Apparently, this is now deprecated and Indy is the 
way to go.  (I even looked into the NetMasters TNMUDP component, but it's 
about the same thing.)

But Indy is a complicated jungle, created by developers who seem to revel in 
its complexity.  The Indy documentation does nothing to change my opinion of 
the work.  The Borland VCL is supposed to be all about RAD and a simplified 
development path, but Indy is running headlong in the opposite direction, 
IMO.  It's complicated and proud of it.

Enough of the rant.

I need help.

Is there a good EXAMPLE of the use of the Indy UDP client?  Maybe I can 
begin to decipher what they're doing with an example.

Thanks, and best regards to all. 



Vote for best question.
Score: 0  # Vote:  0
Date Posted: 16-Nov-2007, at 11:39 PM EST
From: TerryC
 
Re: Indy 9 : UDP Client help?  
News Group: borland.public.cppbuilder.internet.socket
Hi Remy

> You don't need that on the client side.  All it does is allocates the 
> Binding, not establish a connection to the server (since UDP is 
> connectionless).  SendBuffer() will allocate the Binding internally if 
> needed.

Yes, I know, just listed it as an example as it is a property of the 
component.  I should doing that one, bad habits.

> What is EventID supposed to be?  That particular overload of 
> ReceiveBuffer() takes a timeout as the second parameter.

Oops.  Meant to take that bit out, I was modifying my code for the code 
snippets, it should have been "a_timeout_value" as per the Indy 9 example 
code snippet.

Paul



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 22-Nov-2007, at 7:46 AM EST
From: Paul at NCF
 
Re: Indy 9 : UDP Client help?  
News Group: borland.public.cppbuilder.internet.socket
"Paul at NCF"  wrote in message 
news:47448e0d@newsgroups.borland.com...

>    IdUDPClient->Active = true;

You don't need that on the client side.  All it does is allocates the 
Binding, not establish a connection to the server (since UDP is 
connectionless).  SendBuffer() will allocate the Binding internally if 
needed.

>                        RxBuf->Ulength = IdUDPClient->ReceiveBuffer(buf, 
> this_ptr->EventID);

What is EventID supposed to be?  That particular overload of ReceiveBuffer() 
takes a timeout as the second parameter.


Gambit 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 21-Nov-2007, at 12:51 PM EST
From: Remy Lebeau \(TeamB\)
 
Re: Indy 9 : UDP Client help?  
News Group: borland.public.cppbuilder.internet.socket
Hi,

I've not got my full working version of the Indy 9 code, as I was moving to 
Indy 10 a while back, however there's not much to the UDP use, the server 
end is a bit more complicated, but not much.

I've put these client code snippets in a thread, with an input Q to transmit 
data to the server:

    // create client UDP component, set remote connection settings
    IdUDPClient = new TIdUDPClient(NULL);
    IdUDPClient->Host = host_name;
    IdUDPClient->Port = host_port;
    IdUDPClient->ReceiveTimeout = 100;
    IdUDPClient->Active = true;

while (!Terminated)
{
            if (IdUDPClient)
            {
                try
                {
                    // Indy 9:
                        IdUDPClient->SendBuffer( ptr->Udata, ptr->Ulength );

                    // Indy 10:
                        IdUDPClient->SendBuffer(RawToBytes(ptr->Udata, 
ptr->Ulength));

            // if you want a response and want to wait....

                     // Indy 9:
                            RxBuf->Ulength = IdUDPClient->ReceiveBuffer( 
RxBuf->Udata,
                                                                             
                            RxBuf->BufferSize,
                                                                             
                            a_timeout_value );
                     // Indy 10
                        TIdBytes buf;

                        buf.Length = RxBuf->BufferSize;

                        RxBuf->Ulength = IdUDPClient->ReceiveBuffer(buf, 
this_ptr->EventID);

                        BytesToRaw(buf, RxBuf->Udata, RxBuf->Ulength);

Regards,

Paul



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 21-Nov-2007, at 7:59 PM EST
From: Paul at NCF