BUG: Winsock DataArrival Event Fires Multiple Times

Izjava o odricanju odgovornosti za sadržaj o otpisanom proizvodu u bazi znanja

Ovaj je članak napisan o proizvodu za koji Microsoft više ne pruža podršku. Članak će stoga ostati nepromijenjen i više se neće ažurirati.


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."


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
    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
    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.

ID članka: 240747 - posljednja izmjena: 22. lis 2002. - verzija: 1

Povratne informacije