@@ -9,20 +9,34 @@ int main(int argc, char **argv)
99 CPassiveSocket passiveSocket ( CSimpleSocket::SocketTypeUdp );
1010
1111 const char * bindAddr = 0 ;
12+ const char * multicastGroup = 0 ;
1213 unsigned bindPort = 6789 ;
14+ bool bindRet;
15+
1316 if ( argc <= 1 )
14- fprintf (stderr, " usage: %s [<bind-address> [<bind-port>]]\n " , argv[0 ] );
17+ fprintf (stderr, " usage: %s [<bind-address> [<bind-port> [<multicast-group-ip>] ]]\n " , argv[0 ] );
1518 if ( 1 < argc )
1619 bindAddr = argv[1 ];
1720 if ( 2 < argc )
1821 bindPort = atoi (argv[2 ]) & 65535 ;
22+ if ( 3 < argc )
23+ multicastGroup = argv[3 ];
1924
2025 // --------------------------------------------------------------------------
2126 // Initialize our socket object
2227 // --------------------------------------------------------------------------
2328 passiveSocket.Initialize ();
24- fprintf (stderr, " binding to %s:%u\n " , bindAddr, bindPort);
25- passiveSocket.Bind ( bindAddr, uint16 (bindPort) ); // not "127.0.0.1" to allow testing with remotes
29+ if (!multicastGroup)
30+ {
31+ fprintf (stderr, " binding to %s:%u\n " , bindAddr, bindPort);
32+ bindRet = passiveSocket.Bind ( bindAddr, uint16 (bindPort) ); // not "127.0.0.1" to allow testing with remotes
33+ }
34+ else
35+ {
36+ fprintf (stderr, " binding to %s:%u for multicast-group %s\n " , bindAddr, bindPort, multicastGroup);
37+ bindRet = passiveSocket.BindMulticast ( bindAddr, multicastGroup, uint16 (bindPort) );
38+ }
39+ fprintf (stderr, " bind %s\n " , bindRet ? " was successful" : " failed" );
2640 CSimpleSocket &socket = passiveSocket;
2741
2842 fprintf (stderr, " \n Local is %s. Local: %s:%u "
0 commit comments