40 |
|
Top = 2040 |
41 |
|
Width = 1935 |
42 |
|
End |
43 |
< |
Begin MSWinsockLib.Winsock Winsock2 |
43 |
> |
Begin MSWinsockLib.Winsock TCPSock |
44 |
|
Left = 4920 |
45 |
|
Top = 120 |
46 |
|
_ExtentX = 741 |
63 |
|
Top = 600 |
64 |
|
Width = 4935 |
65 |
|
End |
66 |
< |
Begin MSWinsockLib.Winsock Winsock1 |
66 |
> |
Begin MSWinsockLib.Winsock UDPSock |
67 |
|
Left = 4320 |
68 |
|
Top = 120 |
69 |
|
_ExtentX = 741 |
104 |
|
|
105 |
|
Private Sub Command1_Click() |
106 |
|
|
107 |
+ |
' build the contents of the XML packet. |
108 |
|
xml = "<packet></packet>" |
109 |
|
|
110 |
|
' Use the first winsock control to send a UDP packet. |
111 |
< |
Winsock1.RemoteHost = filterHostname |
112 |
< |
Winsock1.RemotePort = filterUDPPort |
113 |
< |
Winsock1.SendData xml |
111 |
> |
UDPSock.RemoteHost = filterHostname |
112 |
> |
UDPSock.RemotePort = filterUDPPort |
113 |
> |
UDPSock.SendData xml |
114 |
|
|
115 |
|
End Sub |
116 |
|
|
117 |
|
Private Sub Command2_Click() |
118 |
|
|
119 |
|
' establish a TCP connection to a filtermanager |
120 |
< |
Winsock2.Close |
121 |
< |
Winsock2.Connect filterManagerHostname, filterManagerTCPPort |
120 |
> |
TCPSock.Close |
121 |
> |
TCPSock.Connect filterManagerHostname, filterManagerTCPPort |
122 |
|
|
123 |
|
End Sub |
124 |
|
|
125 |
|
Private Sub Command3_Click() |
126 |
|
' establish a TCP connection to a filter |
127 |
< |
Winsock2.Close |
128 |
< |
Winsock2.Connect filterHostname, filterTCPPort |
127 |
> |
TCPSock.Close |
128 |
> |
TCPSock.Connect filterHostname, filterTCPPort |
129 |
|
End Sub |
130 |
|
|
131 |
|
Private Sub Form_Load() |
153 |
|
|
154 |
|
End Sub |
155 |
|
|
156 |
< |
Private Sub Label2_Click() |
156 |
< |
|
157 |
< |
End Sub |
158 |
< |
|
159 |
< |
Private Sub Winsock2_Connect() |
156 |
> |
Private Sub TCPSock_Connect() |
157 |
|
|
158 |
|
responseNumber = 0 |
159 |
|
|
160 |
|
' Send something as soon as we connect to the server. |
161 |
|
If connected = False Then |
162 |
|
' contact the FilterManager |
163 |
< |
Winsock2.SendData "STARTCONFIG" & vbCrLf |
163 |
> |
TCPSock.SendData "STARTCONFIG" & vbCrLf |
164 |
|
Else |
165 |
|
' Contact the Filter |
166 |
< |
Winsock2.SendData "HEARTBEAT" & vbCrLf |
166 |
> |
TCPSock.SendData "HEARTBEAT" & vbCrLf |
167 |
|
End If |
168 |
|
|
169 |
|
End Sub |
170 |
|
|
171 |
< |
Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long) |
171 |
> |
Private Sub TCPSock_DataArrival(ByVal bytesTotal As Long) |
172 |
|
|
173 |
|
responseNumber = responseNumber + 1 |
174 |
|
|
175 |
|
' Get the line from the server. |
176 |
< |
Winsock2.GetData response, vbString, bytesTotal |
176 |
> |
TCPSock.GetData response, vbString, bytesTotal |
177 |
|
|
178 |
|
' Remove linefeeds and returns from the line. |
179 |
|
response = Replace(response, Chr(13), "") |
186 |
|
Select Case responseNumber |
187 |
|
Case 1: |
188 |
|
If Not response = "OK" Then GoTo configError |
189 |
< |
Winsock2.SendData "LASTMODIFIED" & vbCrLf |
189 |
> |
TCPSock.SendData "LASTMODIFIED" & vbCrLf |
190 |
|
Case 2: |
191 |
|
If response = "ERROR" Then GoTo configError |
192 |
|
lastModified = response |
193 |
< |
Winsock2.SendData "FILELIST" & vbCrLf |
193 |
> |
TCPSock.SendData "FILELIST" & vbCrLf |
194 |
|
Case 3: |
195 |
|
If response = "ERROR" Then GoTo configError |
196 |
|
fileList = response |
197 |
< |
Winsock2.SendData "UDPUpdateTime" & vbCrLf |
197 |
> |
TCPSock.SendData "UDPUpdateTime" & vbCrLf |
198 |
|
Case 4: |
199 |
|
If response = "ERROR" Then GoTo configError |
200 |
< |
Winsock2.SendData "TCPUpdateTime" & vbCrLf |
200 |
> |
TCPSock.SendData "TCPUpdateTime" & vbCrLf |
201 |
|
Case 5: |
202 |
|
If response = "ERROR" Then GoTo configError |
203 |
< |
Winsock2.SendData "ENDCONFIG" & vbCrLf |
203 |
> |
TCPSock.SendData "ENDCONFIG" & vbCrLf |
204 |
|
Case 6: |
205 |
|
If Not response = "OK" Then GoTo configError |
206 |
< |
Winsock2.SendData "FILTER" & vbCrLf |
206 |
> |
TCPSock.SendData "FILTER" & vbCrLf |
207 |
|
Case 7: |
208 |
|
'we got a filter list here. |
209 |
|
readTo = 0 |
217 |
|
response = Mid(response, readTo + 1, Len(response)) |
218 |
|
' get TCP Port number |
219 |
|
filterTCPPort = response |
220 |
< |
Winsock2.SendData "END" & vbCrLf |
220 |
> |
TCPSock.SendData "END" & vbCrLf |
221 |
|
Case 8: |
222 |
|
If Not response = "OK" Then GoTo configError |
223 |
|
connected = True |
224 |
|
responseNumber = 0 |
225 |
< |
Winsock2.Close |
225 |
> |
TCPSock.Close |
226 |
|
Text4.Text = Text4.Text & vbCrLf & " <closed>" |
227 |
|
x = MsgBox("got config okay") |
228 |
|
End Select |
232 |
|
Select Case responseNumber |
233 |
|
Case 1: |
234 |
|
If Not response = "OK" Then GoTo heartbeatError |
235 |
< |
Winsock2.SendData "CONFIG" & vbCrLf |
235 |
> |
TCPSock.SendData "CONFIG" & vbCrLf |
236 |
|
Case 2: |
237 |
|
If Not response = "OK" Then GoTo heartbeatError |
238 |
< |
Winsock2.SendData fileList & vbCrLf |
238 |
> |
TCPSock.SendData fileList & vbCrLf |
239 |
|
Case 3: |
240 |
|
If Not response = "OK" Then GoTo heartbeatError |
241 |
< |
Winsock2.SendData lastModified & vbCrLf |
241 |
> |
TCPSock.SendData lastModified & vbCrLf |
242 |
|
Case 4: |
243 |
|
If Not response = "OK" Then GoTo heartbeatError |
244 |
< |
Winsock2.SendData "ENDHEARTBEAT" & vbCrLf |
244 |
> |
TCPSock.SendData "ENDHEARTBEAT" & vbCrLf |
245 |
|
Case 5: |
246 |
|
If Not response = "OK" Then GoTo heartbeatError |
247 |
< |
Winsock2.Close |
247 |
> |
TCPSock.Close |
248 |
|
x = MsgBox("heartbeat sent okay.") |
249 |
|
End Select |
250 |
|
|
258 |
|
heartbeatError: |
259 |
|
x = MsgBox("error doing configuration") |
260 |
|
End Sub |
261 |
+ |
|