我有一个MSWinsock的问题,问题是:我有一个带有多个winsock控件的VB.NET应用程序,它们都同时工作,但是当它们都发送数据(Obj.Senddata(data))时,数据其中一些没有被对方收回。
问题是什么?
我有一个MSWinsock的问题,问题是:我有一个带有多个winsock控件的VB.NET应用程序,它们都同时工作,但是当它们都发送数据(Obj.Senddata(data))时,数据其中一些没有被对方收回。
问题是什么?
Private Function PublishTemplateToTerminal()
lblStatus.Text = "Publish in progress..."
Dim DataToSend As String
DataToSend = CType(Me.ParentForm, PublishTemplate).ALFullTemplateDetails.Item(Index)
Index += 1
Winsock.SendData(DataToSend)
Application.DoEvents()
End Function
Private Sub Winsock_DataArrival(ByVal sender As System.Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Winsock.DataArrival
Dim Msg As String = ""
Winsock.GetData(Msg)
ReceivedData &= Msg
If ReceivedData.StartsWith("#999#") = True And ReceivedData.EndsWith("#END#") = True Then
ReceivedData = ReceivedData.Substring(5)
ReceivedData = ReceivedData.Substring(0, ReceivedData.Length - 5)
If ReceivedData.StartsWith("ERROR") = True Then
Winsock.Close()
lblStatus.Text = "Error publish template to terminal!"
lblStatus.BackColor = Color.Red
End If
If ReceivedData.StartsWith("DONE") = True Then
ProgressBar.Value += 1
If Index < CType(Me.ParentForm, PublishTemplate).ALFullTemplateDetails.Count Then
Dim DataToSend As String
DataToSend = CType(Me.ParentForm, PublishTemplate).ALFullTemplateDetails.Item(Index)
Index += 1
Winsock.SendData(DataToSend)
Application.DoEvents()
Else
Winsock.Close()
lblStatus.Text = "Publish Complete"
lblStatus.BackColor = Color.Green
End If
End If
ReceivedData = ""
End If
End Sub