Thread View: borland.public.cppbuilder.internet.socket
4 messages
4 total messages
Started by TerryC
Sat, 17 Nov 2007 06:39
Indy 9 : UDP Client help?
Author: TerryC
Date: Sat, 17 Nov 2007 06:39
Date: Sat, 17 Nov 2007 06:39
19 lines
1612 bytes
1612 bytes
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.
Re: Indy 9 : UDP Client help?
Author: Paul at NCF
Date: Wed, 21 Nov 2007 19:59
Date: Wed, 21 Nov 2007 19:59
51 lines
2646 bytes
2646 bytes
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
Re: Indy 9 : UDP Client help?
Author: Remy Lebeau (TeamB)
Date: Wed, 21 Nov 2007 20:51
Date: Wed, 21 Nov 2007 20:51
19 lines
1637 bytes
1637 bytes
"Paul at NCF" <notplmacca@clara.co.uk> 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
Re: Indy 9 : UDP Client help?
Author: Paul at NCF
Date: Thu, 22 Nov 2007 07:46
Date: Thu, 22 Nov 2007 07:46
18 lines
1702 bytes
1702 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads