Article View: borland.public.cppbuilder.internet.socket
Article #1999Re: Indy UDP in a console app.
From: pedrooz
Date: Mon, 04 Sep 2006 00:02
Date: Mon, 04 Sep 2006 00:02
81 lines
3043 bytes
3043 bytes
Hi Remy,
thanks for the reply.
I'm using Indy 9 in BCB6 and have an IdUDPServer on a data module.
I've put the following in the UDPRead even handler...
char *lpszResult = new char[AData->Size + 1];
AData->ReadBuffer(lpszResult, AData->Size);
lpszResult[AData->Size] = 0;
file << lpszResult << endl;
if(strcmp("die", lpszResult) == 0)
{
m_die = true;
}
delete lpszResult;
but it never gets called.
The Console app has the following main..
int main(int argc, char* argv[])
{
// parse environment variables to get file name
if(argc < 3)
{
// something went wrong, no file handle here
ofstream out("err_log.txt");
out << "Didn't get enough command line parameters" << endl;
return 1;
}
bool die = false;
// create data module.
THiddenDataModule* dm = new THiddenDataModule(NULL, argv[1], die);
dm->file.open(argv[1]);
dm->IdUDPServer->Active = false;
//dm->IdUDPServer->DefaultPort = argv[2];
dm->IdUDPServer->DefaultPort = 4000;
dm->IdUDPServer->Active = true;
// loop
for(;;)
{
Sleep(100);
if(die)
break;
}
return 0;
}
die is a reference to a bool in the constructor.
Thanks agan.
Peter.
Remy Lebeau (TeamB) wrote:
> "Peter Nunn" <pnunn@infotetq.com.au> wrote in message
> news:44f789ba$1@newsgroups.borland.com...
>
> > I've put together a console app with an attached data module
> > following some advice I found searching on here, but for some
> > reason the UDP control never gets a message it seems.
>
> Which component(s) are you using exactly? What does your actual code look
> like?
>
> > Am I missing a process loop or something similar?
>
> Maybe, but it is dificult to say for sure until you provide more details.
>
>
> Gambit
Technical Details
Message-ID:
<1157328150.977474.221710@p79g2000cwp.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!p79g2000cwp.googlegroups.com!not-for-mailReferences:
<44f789ba$1@newsgroups.borland.com> <44f7e8f1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b3954c31c7b052bb X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!p79g2000cwp.googlegroups.com!not-for-mail From: pedrooz@gmail.com Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: Indy UDP in a console app. Date: 3 Sep 2006 17:02:31 -0700 Organization: http://groups.google.com Lines: 82 Message-ID: <1157328150.977474.221710@p79g2000cwp.googlegroups.com> References: <44f789ba$1@newsgroups.borland.com> <44f7e8f1$1@newsgroups.borland.com> NNTP-Posting-Host: 203.5.1.202 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1157328156 6514 127.0.0.1 (4 Sep 2006 00:02:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 4 Sep 2006 00:02:36 +0000 (UTC) In-Reply-To: <44f7e8f1$1@newsgroups.borland.com> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-AU; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: p79g2000cwp.googlegroups.com; posting-host=203.5.1.202; posting-account=B6IEbg0AAABWt2OXjRnx3EJNGwzIxAo9