--- experimental/host/vb_net_test/nettest.frm 2001/02/22 17:04:22 1.1 +++ experimental/host/vb_net_test/nettest.frm 2001/02/23 09:42:36 1.2 @@ -119,13 +119,18 @@ Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False +Dim filterHostname As String +Dim filterTCPPort As String +Dim filterUDPPort As String + +Dim protocolVersion As String +Dim connected As Boolean Dim responseNumber As Integer Private Sub Command1_Click() - ' Use the first winsock control to send - ' a UDP packet. + ' Use the first winsock control to send a UDP packet. Winsock1.RemoteHost = Text3.Text Winsock1.RemotePort = Text2.Text Winsock1.SendData Text1.Text @@ -144,6 +149,10 @@ Private Sub Command3_Click() x = MsgBox("not implemented..") End Sub +Private Sub Form_Load() + protocolVersion = "1.1" +End Sub + Private Sub Winsock2_Connect() responseNumber = 0 @@ -165,25 +174,79 @@ Private Sub Winsock2_DataArrival(ByVal bytesTotal As L response = Replace(response, Chr(10), "") Text4.Text = Text4.Text & vbCrLf & response - ' Decide what to send back to the server. - Select Case responseNumber - Case 1: - Winsock2.SendData "LASTMODIFIED" & vbCrLf - Case 2: - Winsock2.SendData "FILELIST" & vbCrLf - Case 3: - Winsock2.SendData "UDPUpdateTime" & vbCrLf - Case 4: - Winsock2.SendData "TCPUpdateTime" & vbCrLf - Case 5: - Winsock2.SendData "ENDCONFIG" & vbCrLf - Case 6: - Winsock2.SendData "FILTER" & vbCrLf - Case 7: - Winsock2.SendData "END" & vbCrLf - Case 8: - Winsock2.Close - Text4.Text = Text4.Text & vbCrLf & " " - End Select + If connected = False Then + ' Perform TCP configuration (1.1) + On Error GoTo configError + Select Case responseNumber + Case 1: + If Not response = "OK" Then GoTo configError + Winsock2.SendData "LASTMODIFIED" & vbCrLf + Case 2: + If response = "ERROR" Then GoTo configError + Winsock2.SendData "FILELIST" & vbCrLf + Case 3: + If response = "ERROR" Then GoTo configError + Winsock2.SendData "UDPUpdateTime" & vbCrLf + Case 4: + If response = "ERROR" Then GoTo configError + Winsock2.SendData "TCPUpdateTime" & vbCrLf + Case 5: + If response = "ERROR" Then GoTo configError + Winsock2.SendData "ENDCONFIG" & vbCrLf + Case 6: + If Not response = "OK" Then GoTo configError + Winsock2.SendData "FILTER" & vbCrLf + Case 7: + 'we got a filter list here. + readTo = 0 + ' get hostname + readTo = InStr(1, response, ";", vbBinaryCompare) + filterHostname = Mid(response, 1, readTo - 1) + response = Mid(response, readTo + 1, Len(response)) + ' get UDP Port number + readTo = InStr(1, response, ";") + filterUDPPort = Mid(response, 1, readTo - 1) + response = Mid(response, readTo + 1, Len(response)) + ' get TCP Port number + filterTCPPort = response + Winsock2.SendData "END" & vbCrLf + Case 8: + If Not response = "OK" Then GoTo configError + connected = True + responseNumber = 0 + Winsock2.Close + Text4.Text = Text4.Text & vbCrLf & " " + x = MsgBox("got config okay") + End Select + Else + ' Perform a heartbeat (1.1) + On Error GoTo heartbeatError + Select Case responseNumber + Case 1: + + Case 2: + + Case 3: + + Case 4: + + Case 5: + + Case 6: + + Case 7: + + Case 8: + + End Select + + End If + + + Exit Sub + +configError: + x = MsgBox("error doing configuration") +heartbeatError: End Sub