Article View: borland.public.cppbuilder.internet.socket
Article #2686UDP Client/Server broadcasting
From: Lapo Guidi
Date: Tue, 07 Feb 2006 13:50
Date: Tue, 07 Feb 2006 13:50
51 lines
2043 bytes
2043 bytes
Hi all,
I coded a simple UDP Client/Server application.
The problem I have is that when I broadcast using the Client, the OnUDPRead of the Server is fired 2 times, so I receive every data doubled.
If I send datas to a target IP all works fine.
This is a snip of code:
Client--
---
Properties:
Active = true
BroadcastEnabled = true
BufferSize = 8192
Host = (empty string)
Port = 9999
ReceivedTimeout = -2
---
Send function used
UDPClient->Broadcast(Memo1->Lines->Text, 9999);
---
Server
---
Properties:
Active = true
Bindings = (empty)
BroadcastEnabled = true
BufferSize = 8192
DefaultPort = 9999
ThreadedEvent = false
---
Receive function used
void __fastcall TForm1::UDPServerUDPRead(TObject *Sender, TStream *AData,
TIdSocketHandle *ABinding)
{
AnsiString Text="";
if(AData->Size>0) {
int Len=AData->Size-AData->Position;
Text.SetLength(Len);
AData->Read(&Text[1], Len);
Memo1->Lines->Add(Text);
}
}
---
This function is called twice.
Can anybody help me?
Thanks in advance
Lapo
Technical Details
Message-ID:
<43e8b39a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3dbb3fd777ca4bbe,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Lapo Guidi" <lapoguidi@antispam.com> Sender: "Lapo Guidi" <lapoguidi@antispam.com> Reply-To: "Lapo Guidi" <lapoguidi@antispam.com> Subject: UDP Client/Server broadcasting Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 81.123.4.78 NNTP-Posting-Host: 207.105.83.66 Message-ID: <43e8b39a$1@newsgroups.borland.com> Date: 7 Feb 2006 06:50:02 -0700 X-Trace: newsgroups.borland.com 1139323802 207.105.83.66 (7 Feb 2006 06:50:02 -0700) Lines: 51 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail