Board index » delphi » TCP/IP Or/And UDP Multicast/Broadcast Info

TCP/IP Or/And UDP Multicast/Broadcast Info

Hello there coders,

Does anyone know where I can find some could information regarding
Broadcasting/Multicasting with TCP/IP and UDP. I am relatively new so a
brief introduction would be brilliant followed by some more advanced steps.

I have searched google groups already and it was that mainly that peaked my
interest but there wasn't a place listed that I could learn more,
specifically tutorials and code snippets and the like.

Cheers
--
Kind Regards,
Anthoni Gardner

 

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Quote
> Does anyone know where I can find some could information regarding
> Broadcasting/Multicasting with TCP/IP and UDP. I am relatively new so a
> brief introduction would be brilliant followed by some more advanced
> steps.

Ok:

1/ Drop IdUDPClient component on a form.
2/ Set it's "BraodcastEnabled" propertyx to "true".
3/ Create a button and insert the following code in it's OnClick event
handler:

const
  AMessage: string = 'Hello world!';
var
  Data: string;
begin
  IdUDPClient1.Send('255.255.255.255', 3435, Format('%.3d%s',[Length
(AMessage), AMessage]));

Compile, run, click button: You are broadcasting.

now, to receive:

1/ Drop IdUDPServer on a form
2/ Set it's "default port" property to "3435"
3/ Set it's "Enabled" property to "true"
4/ In it's "OnUDPRead" event handler, place the code:

var
  AString: TStringStream;
  StringLength: Integer;
begin
  AString := TStringStream.Create('');
  try
    AString.CopyFrom(AData, 3);
    StringLength:= StrToIntDef(AString.DataString, 0);
    if StringLength> 0 then
    begin
      AString.Size := 0;
      AString.CopyFrom(AData, StringLength);
      ShowMessage(AString.DataString);
    end;
  finally
    AString.Free;
  end;
end;

You're receiving...

Notes:

- "Access denied" errors comes from forgetting to set the
"BroadcastEnabled" property to true
- You might need to be admin to run broadcasting app (not sure).
- You normally can't broadcast beyond your local subnet.
- Broadcasts are eating a lot of ressources on a network. Use it only for
discovery, not for carying the whole exchange.

Enjoy,
Stephane

Quote
> I have searched google groups already and it was that mainly that
> peaked my interest but there wasn't a place listed that I could learn
> more, specifically tutorials and code snippets and the like.

> Cheers
> --
> Kind Regards,
> Anthoni Gardner

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Hello Stephane

Thank you for replying to my message. A few questions, if I may,

1) You say that you normally cant broadcast outside of local subnet, does
this mean I can't say for instance broadcast to yourself (or anyone not on
my IP range)?
2) Is there any tutorials that help me with broadcasting via UDP or
Multicasting?
3) What is the difference between UDP Broadcasting and TCP/IP Multicasting?

I understand the difference between UDP and TCP/IP, where UDP does not
guarantee the recieving of the packets and they could be disjointed, whereas
TCP/IP guarantees their arrival. What I dont understand is the difference
between Broadcasting and Multicasting.

Once again, thanks for your help regarding this.
Anthoni

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Quote
> 1) You say that you normally cant broadcast outside of local subnet,
> does this mean I can't say for instance broadcast to yourself (or
> anyone not on my IP range)?

Yes and no... Broadcasts will go all the way to the first router, but no
further. You can configure that router to pass broadcasts but it's really
not a good idea.

Quote
> 2) Is there any tutorials that help me with broadcasting via UDP or
> Multicasting?

None that I know of. Multicasting is really different from broadcasting.
The princible is that the routers will carry a single TCP stream as much as
possible and only switch the streams when they reach a routine branch or
when they reach the final subnet.

Quote
> 3) What is the difference between UDP Broadcasting and TCP/IP
> Multicasting?

Ah... See above ;)

Quote
> I understand the difference between UDP and TCP/IP, where UDP does not
> guarantee the recieving of the packets and they could be disjointed,
> whereas TCP/IP guarantees their arrival. What I dont understand is the
> difference between Broadcasting and Multicasting.

Broadcasting is "shouting to the wind". You simply put a datagram (packet)
on the wire with an address that tells all machines to pick it up and carry
it to the socket level. This is a costy operation because it doesn't make
the difference between hosts that "wants" the packet and thoses that
actually do not care (there go your switches). Multicasting is more like
sending data only to the hosts that "registered" for it and, as much as
possible, not to duplicate the content between several data stream on the
same wire.

Quote
> Once again, thanks for your help regarding this.

NP,
Good luck,
Stephane

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Stephane,

Wow, what more can I say. Thank you very much this has helped me a great
deal. From what you have put down I have deduced that I need more than
'shouting to the wind' and therefore would like to try Multicasting (always
keen to learn new skills, especially with Delphi). Do you have a possible
example of Multicasting or where I might find such an article?

Cheers for your help. You've helped me lots.
Anthoni

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Quote
> Wow, what more can I say. Thank you very much this has helped me a
> great deal. From what you have put down I have deduced that I need more
> than 'shouting to the wind' and therefore would like to try
> Multicasting (always keen to learn new skills, especially with Delphi).
> Do you have a possible example of Multicasting or where I might find
> such an article?

Sadly, no. I know the principle behind TCP multicast, but I have no
experience with it myself and I do not know of any tutorial. The only
resources that comes to my mind are the relevant RFCs and the "Windows
network programming" book which does give exemples (In C, I'm afraid).

Quote
> Cheers for your help. You've helped me lots.
> Anthoni

Good luck,
Stephane

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


"Anthoni Gardner" <b...@bob.com> wrote in news:3d35e92a$1_1@dnews:

Quote
> 1) You say that you normally cant broadcast outside of local subnet, does
> this mean I can't say for instance broadcast to yourself (or anyone not
> on my IP range)?

Correct unless you send more than one message, or multi cast

Quote
> 3) What is the difference between UDP Broadcasting and TCP/IP
> Multicasting?

Very different - cannot type it in a short message.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Qualified help FAST with Indy Experts Support
   from the experts themselves:

      http://www.atozedsoftware.com/indy/support/

ELKNews Free Edition - Empower your News Reader! http://www.atozedsoftware.com

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


"Chad Z. Hower aka Kudzu" <c...@hower.org> wrote in message
news:Xns924F686DFF218cpub@127.0.0.1...

Quote
> Very different - cannot type it in a short message.

Chad, do you have a URL to a page which describes the differences. I've
never worked with multicasting before and would love to know the difference
between UDP broadcasting and TCP multicasting.

Cheers
Steve

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Quote
> "Chad Z. Hower aka Kudzu" <c...@hower.org> wrote>
> > Very different - cannot type it in a short message.
"Steve" <st...@steve.com> wrote in message news:3d37a34a$1_2@dnews...
> Chad, do you have a URL to a page which describes the differences. I've
> never worked with multicasting before and would love to know the
difference
> between UDP broadcasting and TCP multicasting.

These links have the info, but they're not the easiest read in the world.
<g>

RFC 768 - User Datagram Protocol (http://www.rfc-editor.org/rfc/rfc768.txt)
RFC 1112 - Host Extensions for IP Multicasting.
(http://www.rfc-editor.org/rfc/rfc1112.txt)
RFC 1458 - Requirements for Multicast Protocols.
(http://www.rfc-editor.org/rfc/rfc1458.txt)

--
Don

--

ELKNews - Empower your News Reader! http://www.atozedsoftware.com

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


"Steve" <st...@steve.com> wrote in news:3d37a34a$1_2@dnews:

Quote
> Chad, do you have a URL to a page which describes the differences. I've
> never worked with multicasting before and would love to know the difference
> between UDP broadcasting and TCP multicasting.

Unfortuntely no. Id just search for "IP multicasting". IP multicasting is
based on subscription and can traverse routers (if configured for it), UDP is
a broadcast to all that listen.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Free Demos
    * Free Articles
    * Extra Support

ELKNews Free Edition - Empower your News Reader! http://www.atozedsoftware.com

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


ARRG,

I have tried that and sent client to my friend in US but nothing happened :(

Quote
"Stephane Grobety" <grob...@fulgan.com> wrote in message

news:Xns924EBDDB21CD6grobetyfulgancom@207.105.83.65...
Quote
> > Does anyone know where I can find some could information regarding
> > Broadcasting/Multicasting with TCP/IP and UDP. I am relatively new so a
> > brief introduction would be brilliant followed by some more advanced
> > steps.

> Ok:

> 1/ Drop IdUDPClient component on a form.
> 2/ Set it's "BraodcastEnabled" propertyx to "true".
> 3/ Create a button and insert the following code in it's OnClick event
> handler:

> const
>   AMessage: string = 'Hello world!';
> var
>   Data: string;
> begin
>   IdUDPClient1.Send('255.255.255.255', 3435, Format('%.3d%s',[Length
> (AMessage), AMessage]));

> Compile, run, click button: You are broadcasting.

> now, to receive:

> 1/ Drop IdUDPServer on a form
> 2/ Set it's "default port" property to "3435"
> 3/ Set it's "Enabled" property to "true"
> 4/ In it's "OnUDPRead" event handler, place the code:

> var
>   AString: TStringStream;
>   StringLength: Integer;
> begin
>   AString := TStringStream.Create('');
>   try
>     AString.CopyFrom(AData, 3);
>     StringLength:= StrToIntDef(AString.DataString, 0);
>     if StringLength> 0 then
>     begin
>       AString.Size := 0;
>       AString.CopyFrom(AData, StringLength);
>       ShowMessage(AString.DataString);
>     end;
>   finally
>     AString.Free;
>   end;
> end;

> You're receiving...

> Notes:

> - "Access denied" errors comes from forgetting to set the
> "BroadcastEnabled" property to true
> - You might need to be admin to run broadcasting app (not sure).
> - You normally can't broadcast beyond your local subnet.
> - Broadcasts are eating a lot of ressources on a network. Use it only for
> discovery, not for carying the whole exchange.

> Enjoy,
> Stephane

> > I have searched google groups already and it was that mainly that
> > peaked my interest but there wasn't a place listed that I could learn
> > more, specifically tutorials and code snippets and the like.

> > Cheers
> > --
> > Kind Regards,
> > Anthoni Gardner

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


"Anthoni Gardner" <b...@bob.com> wrote in news:3d39c455_2@dnews:

Quote
> I have tried that and sent client to my friend in US but nothing happened

Broadcasts dont work across routers, otherwise the internet would be full of
traffic.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Want more Indy stuff? Try the Atozed Indy Portal at
        http://www.atozedsoftware.com/
    * More Free Demos
    * Free Articles
    * Extra Support

ELKNews Free Edition - Empower your News Reader! http://www.atozedsoftware.com

Re:TCP/IP Or/And UDP Multicast/Broadcast Info


Thanks Don and Chad! :)

Other Threads