BUG: Winsock DataArrival Event Fires Multiple Times (240747)



The information in this article applies to:

  • Microsoft eMbedded Visual Basic 3.0

This article was previously published under Q240747

SYMPTOMS

When you send a string of data to an eMbedded Visual Basic (eVB) Winsock control, the DataArrival event fires twice. For example, if the string is "This is a string," the DataArrival event may fire two times as "T" and "his is a string."

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Standard EXE project in Visual Basic. Form1 is created by default.
  2. Add a TextBox control, a CommandButton control, and a Winsock control to Form1.
  3. Paste the following code into the code window of Form1:
    Option Explicit
    Private Sub command1_Click()
        Winsock1.Protocol = 0
        Winsock1.Listen
        MsgBox "Port=" & Winsock1.LocalPort & "LocalIP=" & Winsock1.LocalIP
    End Sub
    
    Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
        If Winsock1.State <> 0 Then Winsock1.Close
        Winsock1.Accept requestID
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
        Winsock1.GetData data, vbString, bytesTotal
        MsgBox "DataArrival event fired! Bytes Received: " & bytesTotal
        Text1.Text = Text1.Text & data
    End Sub
    					
  4. Save the Visual Basic project.
  5. Start a new eVB project. Form1 is created by default.
  6. Add three TextBox controls, two CommandButton controls, and one Winsock control to Form1.
  7. Paste the following code into the code window of Form1:
    Option Explicit
    Private Sub Command1_Click()
        WinSock1.LocalPort = 0
        WinSock1.Protocol = 0
        WinSock1.RemotePort = Text2.Text
        WinSock1.RemoteHost = Text1.Text
        WinSock1.Connect
    End Sub
    
    Private Sub Command2_Click()
        WinSock1.SendData Text3.Text
    End Sub
    					
  8. Save and run the eVB project.
  9. Click Command1 on the Visual Basic project to obtain the Visual Basic Winsock Local Port and Local IP values. Copy and paste these values into TextBox1 and TextBox2 on the eVB project to configure the eVB Winsock Remote Port and Remote Host. Click Command1 to connect.
  10. In Textbox3, type This is a string, and click Command2 to send the data to the Visual Basic project. Notice that the DataArrival event fires twice.

Modification Type:MajorLast Reviewed:10/22/2002
Keywords:kbbug kbToolkit KB240747