Microsoft KB Archive/196351

{|
 * width="100%"|

BUG: Setsockopt with IP_MULTICAST_IF Works for Invalid Address

 * }

Q196351

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), used with:
 * the operating system: Microsoft Windows NT 4.0
 * the operating system: Microsoft Windows 2000

-

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.

Additional query words: multicast IP

Keywords : kbnetwork kbAPI kbOSWinNT400bug kbOSWin2000bug kbSDKPlatform kbWinsock kbGrpDSNet

Issue type : kbbug

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch