ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/host/vb_net_test/nettest.frm
Revision: 1.2
Committed: Fri Feb 23 09:42:36 2001 UTC (23 years, 9 months ago) by pjm2
Branch: MAIN
Changes since 1.1: +85 -22 lines
Log Message:
Added version 1.1 of the FilterManager configuration protocol.
Tested and works.

File Contents

# Content
1 VERSION 5.00
2 Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
3 Begin VB.Form Form1
4 BorderStyle = 3 'Fixed Dialog
5 Caption = "TCP/UDP Test program"
6 ClientHeight = 5655
7 ClientLeft = 45
8 ClientTop = 330
9 ClientWidth = 5670
10 LinkTopic = "Form1"
11 MaxButton = 0 'False
12 MinButton = 0 'False
13 ScaleHeight = 5655
14 ScaleWidth = 5670
15 ShowInTaskbar = 0 'False
16 StartUpPosition = 3 'Windows Default
17 Begin VB.CommandButton Command3
18 Caption = "TCP to Filter"
19 Height = 375
20 Left = 3720
21 TabIndex = 9
22 Top = 2520
23 Width = 1575
24 End
25 Begin VB.TextBox Text4
26 Height = 2535
27 Left = 240
28 MultiLine = -1 'True
29 ScrollBars = 2 'Vertical
30 TabIndex = 8
31 Text = "nettest.frx":0000
32 Top = 3000
33 Width = 5055
34 End
35 Begin VB.CommandButton Command2
36 Caption = "TCP to FilterManager"
37 Height = 375
38 Left = 3360
39 TabIndex = 7
40 Top = 2040
41 Width = 1935
42 End
43 Begin MSWinsockLib.Winsock Winsock2
44 Left = 4920
45 Top = 120
46 _ExtentX = 741
47 _ExtentY = 741
48 _Version = 393216
49 End
50 Begin VB.TextBox Text3
51 Height = 285
52 Left = 1680
53 TabIndex = 5
54 Text = "killigrew.ukc.ac.uk"
55 Top = 1560
56 Width = 2535
57 End
58 Begin VB.TextBox Text2
59 Height = 285
60 Left = 1680
61 TabIndex = 3
62 Text = "4567"
63 Top = 1920
64 Width = 855
65 End
66 Begin VB.CommandButton Command1
67 Caption = "Send UDP"
68 Height = 375
69 Left = 4320
70 TabIndex = 2
71 Top = 1560
72 Width = 975
73 End
74 Begin VB.TextBox Text1
75 Height = 855
76 Left = 360
77 TabIndex = 0
78 Text = "<packet></packet>"
79 Top = 600
80 Width = 4935
81 End
82 Begin MSWinsockLib.Winsock Winsock1
83 Left = 4320
84 Top = 120
85 _ExtentX = 741
86 _ExtentY = 741
87 _Version = 393216
88 Protocol = 1
89 End
90 Begin VB.Label Label3
91 Alignment = 1 'Right Justify
92 Caption = "Destination:"
93 Height = 255
94 Left = 360
95 TabIndex = 6
96 Top = 1560
97 Width = 1215
98 End
99 Begin VB.Label Label2
100 Alignment = 1 'Right Justify
101 Caption = "Port:"
102 Height = 255
103 Left = 360
104 TabIndex = 4
105 Top = 1920
106 Width = 1215
107 End
108 Begin VB.Label Label1
109 Caption = "Packet contents"
110 Height = 255
111 Left = 360
112 TabIndex = 1
113 Top = 360
114 Width = 2895
115 End
116 End
117 Attribute VB_Name = "Form1"
118 Attribute VB_GlobalNameSpace = False
119 Attribute VB_Creatable = False
120 Attribute VB_PredeclaredId = True
121 Attribute VB_Exposed = False
122 Dim filterHostname As String
123 Dim filterTCPPort As String
124 Dim filterUDPPort As String
125
126 Dim protocolVersion As String
127 Dim connected As Boolean
128 Dim responseNumber As Integer
129
130
131 Private Sub Command1_Click()
132
133 ' Use the first winsock control to send a UDP packet.
134 Winsock1.RemoteHost = Text3.Text
135 Winsock1.RemotePort = Text2.Text
136 Winsock1.SendData Text1.Text
137
138 End Sub
139
140 Private Sub Command2_Click()
141
142 ' establish a TCP connection to a machine
143 Winsock2.Close
144 Winsock2.Connect Text3.Text, Text2.Text
145
146 End Sub
147
148 Private Sub Command3_Click()
149 x = MsgBox("not implemented..")
150 End Sub
151
152 Private Sub Form_Load()
153 protocolVersion = "1.1"
154 End Sub
155
156 Private Sub Winsock2_Connect()
157
158 responseNumber = 0
159
160 ' As soon as we are connected to the server, send this.
161 Winsock2.SendData "STARTCONFIG" & vbCrLf
162
163 End Sub
164
165 Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
166
167 responseNumber = responseNumber + 1
168
169 ' Get the line from the server.
170 Winsock2.GetData response, vbString, bytesTotal
171
172 ' Remove linefeeds and returns from the line.
173 response = Replace(response, Chr(13), "")
174 response = Replace(response, Chr(10), "")
175 Text4.Text = Text4.Text & vbCrLf & response
176
177 If connected = False Then
178 ' Perform TCP configuration (1.1)
179 On Error GoTo configError
180 Select Case responseNumber
181 Case 1:
182 If Not response = "OK" Then GoTo configError
183 Winsock2.SendData "LASTMODIFIED" & vbCrLf
184 Case 2:
185 If response = "ERROR" Then GoTo configError
186 Winsock2.SendData "FILELIST" & vbCrLf
187 Case 3:
188 If response = "ERROR" Then GoTo configError
189 Winsock2.SendData "UDPUpdateTime" & vbCrLf
190 Case 4:
191 If response = "ERROR" Then GoTo configError
192 Winsock2.SendData "TCPUpdateTime" & vbCrLf
193 Case 5:
194 If response = "ERROR" Then GoTo configError
195 Winsock2.SendData "ENDCONFIG" & vbCrLf
196 Case 6:
197 If Not response = "OK" Then GoTo configError
198 Winsock2.SendData "FILTER" & vbCrLf
199 Case 7:
200 'we got a filter list here.
201 readTo = 0
202 ' get hostname
203 readTo = InStr(1, response, ";", vbBinaryCompare)
204 filterHostname = Mid(response, 1, readTo - 1)
205 response = Mid(response, readTo + 1, Len(response))
206 ' get UDP Port number
207 readTo = InStr(1, response, ";")
208 filterUDPPort = Mid(response, 1, readTo - 1)
209 response = Mid(response, readTo + 1, Len(response))
210 ' get TCP Port number
211 filterTCPPort = response
212 Winsock2.SendData "END" & vbCrLf
213 Case 8:
214 If Not response = "OK" Then GoTo configError
215 connected = True
216 responseNumber = 0
217 Winsock2.Close
218 Text4.Text = Text4.Text & vbCrLf & " <closed>"
219 x = MsgBox("got config okay")
220 End Select
221 Else
222 ' Perform a heartbeat (1.1)
223 On Error GoTo heartbeatError
224 Select Case responseNumber
225 Case 1:
226
227 Case 2:
228
229 Case 3:
230
231 Case 4:
232
233 Case 5:
234
235 Case 6:
236
237 Case 7:
238
239 Case 8:
240
241 End Select
242
243 End If
244
245
246 Exit Sub
247
248 configError:
249 x = MsgBox("error doing configuration")
250 heartbeatError:
251
252 End Sub