Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any functional difference in using Socket or UdpClient for multicasting?

I am familiarizing myself with Multicasting and such.

There are 2 primary examples used:

  1. Using Socket with Bind()

  2. UDPClient.JoinMulticastNetwork()

One specifiying a LeaveMulticastGroup and another binding and Joining with no LeaveMulticastGroup()

What is the difference between the 2 methods of Multicasting, which is preferable to use?

like image 877
CybeX Avatar asked Jan 13 '16 11:01

CybeX


People also ask

What is UdpClient c#?

The UdpClient class provides simple methods for sending and receiving connectionless UDP datagrams in blocking synchronous mode. Because UDP is a connectionless transport protocol, you do not need to establish a remote host connection prior to sending and receiving data.

What is JoinMulticastGroup?

JoinMulticastGroup(IPAddress) Adds a UdpClient to a multicast group. JoinMulticastGroup(Int32, IPAddress) Adds a UdpClient to a multicast group.

Can UDP be used for Unicast?

Unicast is in contrast to multicast and broadcast which are one-to-many transmissions. Internet Protocol unicast delivery methods such as Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are typically used.


1 Answers

The difference is in the level of abstraction between using a UdpClient class and managing your multicast on a lower level, using sockets and multicast option. If you use a UdpClient, then you don't need to worry about sockets and multicast options, since that is done under the hood in the UdpClient class. If you want more control over what is happening, than you can use a more low-level approach with socket and multicast option.

It is probably easier to implement basic multicasting functionality by using a UdpClient.

For reference, you can check the following two tutorials (the first uses a UdpClient and is more high-level, while the second uses sockets and multicast option):

  1. UDP Multicasting Tutorial
  2. IP Multicasting in C#
like image 61
Igor Ševo Avatar answered Sep 18 '22 15:09

Igor Ševo