🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #731

Re: Indy 9 : UDP Client help?

#731
From: Paul at NCF
Date: Wed, 21 Nov 2007 19:59
51 lines
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
Technical Details
Message-ID: <47448e0d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <473e8cb8@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,d5288f71dfc08357
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Paul at NCF" <notplmacca@clara.co.uk>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <473e8cb8@newsgroups.borland.com>
Subject: Re: Indy 9 : UDP Client help?
Date: Wed, 21 Nov 2007 19:59:11 -0000
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 86.146.89.202
Message-ID: <47448e0d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195675149 86.146.89.202 (21 Nov 2007 11:59:09 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail