Reading Socket Options

Windows CE 3.0

The TTL of a multicast for a socket can be determined by reading the value from the socket options. The following code example shows how the TTL value is read.

int ttl;  // Allocate space for TTL.
int sizeofttl = sizeof(ttl); // Create an integer that contains the size of the TTL value.
            (char *)&ttl,

The ttl parameter in the preceding code example contains the current TTL set value for the multicasts through a socket defined as sock.

Each multicast transmission is sent from a single network interface, even if the host has more than one multicasting-capable interface. The following code example shows how a socket option is available to determine which interface is currently used for transmissions from a specified socket.

unsigned long addr;            //Allocate space for address.
int sizeofaddr = sizeof(addr); //Create an integer containing size of
            (char *)&addr, 
           &sizeofaddr );

The addr parameter contains the local IP address of the current outgoing interface after a getsockopt call.

By default, if a multicast datagram is sent to a group, to which the sending host belongs, a copy of the datagram on the outgoing interface is looped back by IP for local delivery. Any attempt to disable this multicast loop-back results in the call failing with the error message WSAENOPROTOOPT.

 Last updated on Friday, April 02, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.