Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Indy UDP Broadcasting

752 views
Skip to first unread message

Derek Parsons

unread,
Jan 19, 2001, 4:35:02 PM1/19/01
to
Hello,

Being new to using Interent comms I have been writing small demo programs to
get simple communications between two programs on the same machine working.
The TCP and UDP messaging was no problem.

But I have been trying to get UDP broadcasting working for the last week or
so. Although this has been mentioned before by someone, the responses didn't
help me get anywhere.
I have two programs both running on the same machine. The server has the
following procedures. The program only has a UDPServer component on it. The
commented out IdUDPServer1.Send(.) was used to demonstrate the UDP
messaging, which worked so both programs can 'see' each other.

The Server :-
Server properties :-
Broadcast Enabled : False. (But have tried setting this to true)
Default port : 8000

procedure TUDPServer.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
DataStringStream: TStringStream;
begin
DataStringStream := TStringStream.Create('');
try
DataStringStream.CopyFrom(AData, AData.Size);
Label2.Caption := DataStringStream.DataString;
// IdUDPServer1.Send(ABinding.PeerIP, ABinding.PeerPort, 'Hello from
the server');
finally
DataStringStream.Free;
end;
end;

procedure TUDPServer.FormCreate(Sender: TObject);
begin
IdUDPServer1.Active := TRUE;
end;
The client only has a button and an UDPClient component. I expect to see the
message 'Broadcast message' appearing in the label2 caption on the server.

The Client :-
Client properties :-
Broadcast Enabled : False. (But have tried setting this to true)
Host 127.0.0.1
Port : 8000

procedure TForm1.Button2Click(Sender: TObject);
begin
IdUDPClient1.Broadcast('Broadcast message', 8000);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
IdUDPClient1.Active := TRUE;
end;


But nothing ever happens. I have managed to get straight TCP and UDP
communications demonstrated between a client and server on the same machine,
but cannot see why the UDP broadcast method does not work for me.

Can anyone spot the mistake?

Thanks in advance.

(Indy 8.0.16. Windows 98. Delphi 5.0)

Rune Moberg

unread,
Jan 19, 2001, 4:47:50 PM1/19/01
to
Derek Parsons wrote:
> Server properties :-
> Broadcast Enabled : False. (But have tried setting this to true)

Doesn't matter what you set it to on the receiving side.

> Broadcast Enabled : False. (But have tried setting this to true)

Doesn't matter if you use the Broadcast method.

> procedure TForm1.Button2Click(Sender: TObject);
> begin
> IdUDPClient1.Broadcast('Broadcast message', 8000);
> end;

Hmm... Really?

> But nothing ever happens. I have managed to get straight TCP and UDP
> communications demonstrated between a client and server on the same machine,
> but cannot see why the UDP broadcast method does not work for me.

Have you checked out the UDPChargenAndEcho Indy demo? (I just tested it,
and it still works ;-) )

What I did when I originally tested the broadcast stuff, was to install
MS Network Monitor (included with Windows 2000 Server). Using that tool,
it became incredible easy to see when the client had successfully
broadcasted a packet...

--
Rune

Derek Parsons

unread,
Jan 20, 2001, 5:11:02 AM1/20/01
to
Thanks for the tips. But where do you get the UDPChargenAndEcho Indy demo?
I've looked through all the demos that the Indy installation created, and
cannot see it!!

Derek.


Rune Moberg <rmo...@arxi.no> wrote in message
news:3A68B606...@arxi.no...

Rune Moberg

unread,
Jan 20, 2001, 6:16:32 PM1/20/01
to
Derek Parsons wrote:
> Thanks for the tips. But where do you get the UDPChargenAndEcho Indy demo?
> I've looked through all the demos that the Indy installation created, and
> cannot see it!!

Probably a mishap in the build process. I've E-Mailed you the demo
project. HTH.

--
Rune

0 new messages