BUG: Setsockopt with IP_MULTICAST_IF Works for Invalid Address (196351)



The information in this article applies to:

  • Microsoft Platform Software Development Kit (SDK) 1.0, when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000

This article was previously published under Q196351

SYMPTOMS

The IP_MULTICAST_IF option and an IP address are passed to the setsockopt() API to specify which interface should be used for outgoing multicast packets. If you attempt to set this option to an invalid IP address, the function does not return an error.

This occurs only if setsockopt is called before bind. Once the socket is bound to a local interface, if you attempt to set the multicast interface to an invalid address, it fails.

CAUSE

Winsock itself does not recognize addresses. The TCP/IP stack does not validate the address supplied until a call to bind is made. Although setsockopt with invalid IP address succeeds, the subsequent bind fails.

RESOLUTION

Ensure that the interface supplied to setsockopt is valid. Use the Winsock ioctl command SIO_GET_INTERFACE_LIST to obtain a list of valid interface addresses.

NOTE: This ioctl is only available in Winsock 2.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

Modification Type:MinorLast Reviewed:7/11/2005
Keywords:kbAPI kbBug kbnetwork kbWinsock KB196351