Elsevier-Morgan Kaufmann Publishers
  Code Examples Download Page

Multicast Sockets
Practical Guide for Programmers

David Makofske and Kevin Almeroth
The Practical Guides Series
November 2002
175 pages
Paperback
$19.95
ISBN 1-55860-846-X

Below is the source code and errata from the book "Multicast Sockets: Practical Guide for Programmers". This book can be purchased on the book's official web site, at your local bookstore, or at your favorite online book retailer.

Please note the disclaimer for the code provided. If you have any problems with this page, email david_makofske@yahoo.com.


Errata

  • On Page 31, the IP address passed as an argument to mcreceive should be the same as the argument to mcsend. The correct command line is:
    % mcreceive 239.255.10.10 9000
    

  • On Page 54, in the code snippet:
    sock.SetSocketOption(SocketOptionLevel.Socket,
                         SocketOptionName.MulticastTimeToLive,
                         ttl);
    The correct socket option level should be the IP level, not the socket level. The correct code should read:
    sock.SetSocketOption(SocketOptionLevel.IP,
                         SocketOptionName.MulticastTimeToLive,
                         ttl);

C Examples

How to Compile

  • You should have gcc (GNU C compiler) installed for Unix-based systems.

  • Linux, BSD:
    gcc -o mcsend mcsend.c
    Solaris:
    gcc -o mcsend mcsend.c -lsocket -lnsl
  • The Winsock version comes with a makefile for a command line build, or it can be imported into Visual Studio for compilation.

Chapter 2: Multicasting with C Sockets

Chapter 7: Multicast Reachability and Scalability

  • c_mping.tar.gz - Multicast Ping Program (mping.c and mping.h)
  • c_mping2.tar.gz - Multicast Ping Program with Congestion Control (mping.c and mping.h)

Java Examples

How to Compile

  • You will need to download and install the Java JDK from the java.sun.com website.

  • All of the Java examples can be compiled by using:
    javac *.java
    and run using:
    java <program_name> <arguments>
  • As specified in the book, some of the Java multicast API will require JDK 1.4 or higher.

Chapter 3: Multicasting with Java

Chapter 8: Application Layer Multicast and Reflectors

  • java_reflector.tar.gz - Multicast Reflector Program (Reflector.java, ReflectorListener.java, ReflectorSender.java, PacketListenerInterface.java, Logger.java, Address.java)

C# Examples

How to Compile

  • You will need to download and install the .NET Framework from the http://msdn.microsoft.com/netframework/ website.

  • All of the C# examples can be compiled from the command line using:
    csc *.cs
    and run using:
    <program_name>.exe
  • You may also import the C# files into Visual Studio.NET for compilation.

Chapter 4: Multicasting with .NET


Disclaimer: The purpose of this book is to provide general information about multicast network programming as of the book's publication date. The authors have included sample code that is intended for the sole purpose of illustrating the use of the multicasting socket APIs. Neither the authors nor the publisher are aware of any third party patents or proprietary rights that may cover any sample of any kind. The authors and the Publisher DISCLAIM ALL EXPRESS AND IMPLIED WARRANTIES, including warranties of merchantability and fitness for any particular purpose. Your use or reliance upon any sample code or other information in this book will be at your own risk. No one should use any sample code (or illustrations) from this book in any software application without first obtaining competent legal advice.