Article ID: 245159 - Last Review: August 7, 2007 - Revision: 2.3

FIX: Winsock Control SendData Only Works Over the Latest Connection

This article was previously published under Q245159
Expand all | Collapse all

SYMPTOMS

For a 32-bit Visual Basic application with multiple Winsock Control objects that maintain TCP connections to other socket applications, SendData() only works over the most recently established connection. This behavior is reproducible on versions prior to and include Microsoft Visual Studio SP3.

CAUSE

The event messages associated with each SendData() are flushed from the message queue by the latest socket connection. This causes data to queue up and with no event messages available to start the data send process for previous connections.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.

For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:
194022  (http://support.microsoft.com/kb/194022/EN-US/ ) INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295  (http://support.microsoft.com/kb/194295/EN-US/ ) HOWTO: Tell That a Visual Studio Service Pack Is Installed
To download the latest Visual Studio service pack, visit the following Microsoft Web site:
http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx (http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx)

MORE INFORMATION

To reproduce the problem assuming an application maintains an array of three Winsock Control objects, each of controls has established a connection with its peer side over TCP. Label the connections as C1, C2, and C3 based on the order the connections are established, with C3 as the most recently established connection. If you attempt to do the following:
   Private Sub cmdSendData_Click()
       Dim i As Long
       For i = 1 To iIndex
           If (socks(i).State = sckConnected) Then
               socks(i).SendData txtSendData.Text
           End If
       Next i
   End Sub
				
Only the peer side of C3 connection get the messages. If you disconnect C3, the peer side of C2, which becomes the most recent connection at the time, will start to receive messages intended for it.

REFERENCES

For additional information, see the following article or articles in the Microsoft Knowledge Base:
183987  (http://support.microsoft.com/kb/183987/EN-US/ ) PRB: SendData Method Generates Error 40006

APPLIES TO
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition
Keywords: 
kbhotfixserver kbqfe kbdswnet2003swept kbbug kbctrl kbfix kbnetwork kbvs600sp4fix kbvs600sp5fix kbwinsock KB245159
 

Article Translations