Article ID: 192564 - Last Review: November 18, 2003 - Revision: 2.0

INFO: Set Winsock Control RemoteHost and RemotePort for UDP

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q192564
Expand all | Collapse all

SUMMARY

When a UDP message is received by a Winsock control, the RemoteHostIP property is set to the IP address of the remote machine, and the RemotePort property is set to the IP port of the remote UDP application. The previous properties values are overwritten.

This could create a problem if the user was not expecting data on that port from a different RemoteHostIP. Attempts to call the SendData method without setting these two properties to the appropriate values might send the data to an unplanned recipient.

Whenever a UDP socket is being used, you should always reset the RemoteHostIP and RemotePort properties to your own known values before calling the SendData method.

MORE INFORMATION

This is by design. At the Winsock layer, the sendto API requires a sockaddr structure of the remote UDP peer to send the message to, and the recvfrom API always gets a sockaddr structure for the remote UDP peer. The Winsock control internally uses the same sockaddr structure in both sendto and recvfrom API. As UDP is a connectionless protocol, it is possible that one UDP peer could receive a UDP message from a third machine unexpectedly. Therefore, it is important to reset the RemoteHostIP and RemotePort properties to your own known values before calling the SendData method.

APPLIES TO
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
Keywords: 
kbinfo KB192564
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.