ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/host/vb_net_test/nettest.frm
(Generate patch)

Comparing experimental/host/vb_net_test/nettest.frm (file contents):
Revision 1.4 by pjm2, Fri Feb 23 10:29:16 2001 UTC vs.
Revision 1.12 by pjm2, Fri Feb 23 12:01:14 2001 UTC

# Line 1 | Line 1
1   VERSION 5.00
2   Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
3 + Object = "{33155A3D-0CE0-11D1-A6B4-444553540000}#1.0#0"; "SysTray.ocx"
4   Begin VB.Form Form1
5 <   BorderStyle     =   3  'Fixed Dialog
6 <   Caption         =   "TCP/UDP Test program"
5 >   BorderStyle     =   4  'Fixed ToolWindow
6 >   Caption         =   "i-scream Winhost"
7     ClientHeight    =   5655
8     ClientLeft      =   45
9 <   ClientTop       =   330
10 <   ClientWidth     =   5670
9 >   ClientTop       =   285
10 >   ClientWidth     =   4710
11     LinkTopic       =   "Form1"
12     MaxButton       =   0   'False
12   MinButton       =   0   'False
13     ScaleHeight     =   5655
14 <   ScaleWidth      =   5670
14 >   ScaleWidth      =   4710
15     ShowInTaskbar   =   0   'False
16     StartUpPosition =   3  'Windows Default
17 <   Begin VB.CommandButton Command3
18 <      Caption         =   "TCP to Filter"
17 >   Begin VB.CommandButton Hide
18 >      Caption         =   "Hide Window"
19        Height          =   375
20 <      Left            =   3720
21 <      TabIndex        =   5
22 <      Top             =   2520
23 <      Width           =   1575
20 >      Left            =   3120
21 >      TabIndex        =   7
22 >      Top             =   840
23 >      Width           =   1455
24     End
25 +   Begin SysTray.SystemTray SystemTray
26 +      Left            =   2160
27 +      Top             =   1800
28 +      _ExtentX        =   847
29 +      _ExtentY        =   847
30 +      SysTrayText     =   "i-scream Winhost"
31 +      IconFile        =   0
32 +   End
33 +   Begin VB.Timer Timer1
34 +      Left            =   2760
35 +      Top             =   1800
36 +   End
37     Begin VB.TextBox Text4
38 <      Height          =   2535
38 >      Height          =   1575
39        Left            =   240
40        MultiLine       =   -1  'True
41        ScrollBars      =   2  'Vertical
42 <      TabIndex        =   4
42 >      TabIndex        =   1
43        Text            =   "nettest.frx":0000
44        Top             =   3000
45 <      Width           =   5055
45 >      Width           =   3975
46     End
47 <   Begin VB.CommandButton Command2
48 <      Caption         =   "TCP to FilterManager"
47 >   Begin VB.CommandButton Reconfigure
48 >      Caption         =   "Reconfigure with FilterManager"
49        Height          =   375
50 <      Left            =   3360
51 <      TabIndex        =   3
52 <      Top             =   2040
53 <      Width           =   1935
50 >      Left            =   120
51 >      TabIndex        =   0
52 >      Top             =   840
53 >      Width           =   2895
54     End
55 <   Begin MSWinsockLib.Winsock Winsock2
56 <      Left            =   4920
57 <      Top             =   120
55 >   Begin MSWinsockLib.Winsock TCPSock
56 >      Left            =   3720
57 >      Top             =   1800
58        _ExtentX        =   741
59        _ExtentY        =   741
60        _Version        =   393216
61     End
62 <   Begin VB.CommandButton Command1
63 <      Caption         =   "Send UDP"
64 <      Height          =   375
53 <      Left            =   4320
54 <      TabIndex        =   2
55 <      Top             =   1560
56 <      Width           =   975
57 <   End
58 <   Begin VB.TextBox Text1
59 <      Height          =   855
60 <      Left            =   360
61 <      TabIndex        =   0
62 <      Text            =   "<packet></packet>"
63 <      Top             =   600
64 <      Width           =   4935
65 <   End
66 <   Begin MSWinsockLib.Winsock Winsock1
67 <      Left            =   4320
68 <      Top             =   120
62 >   Begin MSWinsockLib.Winsock UDPSock
63 >      Left            =   3240
64 >      Top             =   1800
65        _ExtentX        =   741
66        _ExtentY        =   741
67        _Version        =   393216
68        Protocol        =   1
69     End
70 +   Begin VB.Label Label2
71 +      Alignment       =   1  'Right Justify
72 +      Caption         =   "Next heartbeat:"
73 +      Height          =   255
74 +      Left            =   2400
75 +      TabIndex        =   6
76 +      Top             =   480
77 +      Width           =   1455
78 +   End
79     Begin VB.Label Label1
80 <      Caption         =   "Packet contents"
80 >      Alignment       =   1  'Right Justify
81 >      Caption         =   "Next UDP packet:"
82        Height          =   255
83 <      Left            =   360
84 <      TabIndex        =   1
85 <      Top             =   360
86 <      Width           =   2895
83 >      Left            =   2400
84 >      TabIndex        =   5
85 >      Top             =   120
86 >      Width           =   1455
87     End
88 +   Begin VB.Label Label4
89 +      BorderStyle     =   1  'Fixed Single
90 +      Caption         =   "0"
91 +      Height          =   255
92 +      Left            =   3960
93 +      TabIndex        =   4
94 +      Top             =   480
95 +      Width           =   615
96 +   End
97 +   Begin VB.Label Label3
98 +      BorderStyle     =   1  'Fixed Single
99 +      Caption         =   "0"
100 +      Height          =   255
101 +      Left            =   3960
102 +      TabIndex        =   3
103 +      Top             =   120
104 +      Width           =   615
105 +   End
106 +   Begin VB.Label Status
107 +      Alignment       =   2  'Center
108 +      Caption         =   "Status:"
109 +      Height          =   255
110 +      Left            =   120
111 +      TabIndex        =   2
112 +      Top             =   1320
113 +      Width           =   4455
114 +   End
115   End
116   Attribute VB_Name = "Form1"
117   Attribute VB_GlobalNameSpace = False
# Line 97 | Line 130 | Dim filterUDPPort As Integer
130   Dim fileList As String
131   Dim lastModified As String
132  
133 + Dim UDPUpdateTime As Integer
134 + Dim TCPUpdateTime As Integer
135 +
136   Dim protocolVersion As String
137   Dim connected As Boolean
138   Dim responseNumber As Integer
# Line 104 | Line 140 | Dim responseNumber As Integer
140  
141   Private Sub Command1_Click()
142  
143 +    ' build the contents of the XML packet.
144      xml = "<packet></packet>"
145  
146      ' Use the first winsock control to send a UDP packet.
147 <    Winsock1.RemoteHost = filterHostname
148 <    Winsock1.RemotePort = filterUDPPort
149 <    Winsock1.SendData xml
147 >    UDPSock.RemoteHost = filterHostname
148 >    UDPSock.RemotePort = filterUDPPort
149 >    UDPSock.SendData xml
150 >    Status.Caption = "i-scream Winhost " & protocolVersion & " - UDP packet sent."
151  
152   End Sub
153  
116 Private Sub Command2_Click()
117    
118    ' establish a TCP connection to a filtermanager
119    Winsock2.Close
120    Winsock2.Connect filterManagerHostname, filterManagerTCPPort
154  
122 End Sub
123
155   Private Sub Command3_Click()
156      ' establish a TCP connection to a filter
157 <    Winsock2.Close
158 <    Winsock2.Connect filterHostname, filterTCPPort
157 >    TCPSock.Close
158 >    TCPSock.Connect filterHostname, filterTCPPort
159   End Sub
160  
161   Private Sub Form_Load()
162      protocolVersion = "1.1"
163 +      
164 +    Status.Caption = "Loading"
165 +    Form1.Caption = "i-scream Winhost " & protocolVersion
166      
167      ''''TEMP
168      filterManagerHostname = "killigrew.ukc.ac.uk"
169      filterManagerTCPPort = 4567
170 +    Reconfigure_Click
171      Exit Sub
172      ''' ENDTEMP
173      
# Line 144 | Line 179 | Private Sub Form_Load()
179      length = GetPrivateProfileString("i-scream Winhost", "FilterManagerPort", "<no value>", buf, Len(buf), App.Path & "winhost.ini")
180      filterManagerTCPPort = Left$(buf, length)
181      
182 +    Status.Caption = "Connecting to Filter Manager"
183 +    
184      Exit Sub
185      
186   iniError:
# Line 152 | Line 189 | iniError:
189      
190   End Sub
191  
192 < Private Sub Label2_Click()
192 > Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
193 >    x = MsgBox("Are you sure you want to shut down the Winhost?  This will stop your computer sending information to the i-scream Central Monitoring System.", vbYesNo, "i-scream Winhost")
194 >    If x = 7 Then
195 >        Cancel = True
196 >    End If
197 >    SystemTray.Action = 2
198  
199   End Sub
200  
201 < Private Sub Winsock2_Connect()
202 <      
203 <   responseNumber = 0
201 > Private Sub Hide_Click()
202 >    Form1.Visible = False
203 >    SystemTray.Icon = Val(Form1.Icon)
204 >    SystemTray.Action = 0
205 > End Sub
206 >
207 > Private Sub Reconfigure_Click()
208 >    ' establish a TCP connection to a filtermanager
209 >    connected = False
210 >    TCPSock.Close
211 >    TCPSock.Connect filterManagerHostname, filterManagerTCPPort
212 > End Sub
213 >
214 >
215 >
216 > Private Sub SystemTray_MouseDblClk(ByVal Button As Integer)
217 >
218 >    Form1.Visible = True
219 >    SystemTray.Action = 2
220 >    Form1.SetFocus
221 >    
222 >
223 > End Sub
224 >
225 > Private Sub TCPSock_Connect()
226 >    
227 >    responseNumber = 0
228    
229      ' Send something as soon as we connect to the server.
230      If connected = False Then
231          ' contact the FilterManager
232 <        Winsock2.SendData "STARTCONFIG" & vbCrLf
232 >        TCPSock.SendData "STARTCONFIG" & vbCrLf
233      Else
234         ' Contact the Filter
235 <       Winsock2.SendData "HEARTBEAT" & vbCrLf
235 >       TCPSock.SendData "HEARTBEAT" & vbCrLf
236      End If
237    
238   End Sub
239  
240 < Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
240 > Private Sub TCPSock_DataArrival(ByVal bytesTotal As Long)
241      
242      responseNumber = responseNumber + 1
243      
244      ' Get the line from the server.
245 <    Winsock2.GetData response, vbString, bytesTotal
245 >    TCPSock.GetData response, vbString, bytesTotal
246      
247      ' Remove linefeeds and returns from the line.
248      response = Replace(response, Chr(13), "")
# Line 189 | Line 255 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
255          Select Case responseNumber
256              Case 1:
257                  If Not response = "OK" Then GoTo configError
258 <                Winsock2.SendData "LASTMODIFIED" & vbCrLf
258 >                TCPSock.SendData "LASTMODIFIED" & vbCrLf
259              Case 2:
260                  If response = "ERROR" Then GoTo configError
261                  lastModified = response
262 <                Winsock2.SendData "FILELIST" & vbCrLf
262 >                TCPSock.SendData "FILELIST" & vbCrLf
263              Case 3:
264                  If response = "ERROR" Then GoTo configError
265                  fileList = response
266 <                Winsock2.SendData "UDPUpdateTime" & vbCrLf
266 >                TCPSock.SendData "UDPUpdateTime" & vbCrLf
267              Case 4:
268                  If response = "ERROR" Then GoTo configError
269 <                Winsock2.SendData "TCPUpdateTime" & vbCrLf
269 >                UDPUpdateTime = response
270 >                TCPSock.SendData "TCPUpdateTime" & vbCrLf
271              Case 5:
272                  If response = "ERROR" Then GoTo configError
273 <                Winsock2.SendData "ENDCONFIG" & vbCrLf
273 >                TCPUpdateTime = response
274 >                TCPSock.SendData "ENDCONFIG" & vbCrLf
275              Case 6:
276                  If Not response = "OK" Then GoTo configError
277 <                Winsock2.SendData "FILTER" & vbCrLf
277 >                TCPSock.SendData "FILTER" & vbCrLf
278              Case 7:
279                  'we got a filter list here.
280                  readTo = 0
# Line 220 | Line 288 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
288                  response = Mid(response, readTo + 1, Len(response))
289                  ' get TCP Port number
290                  filterTCPPort = response
291 <                Winsock2.SendData "END" & vbCrLf
291 >                TCPSock.SendData "END" & vbCrLf
292              Case 8:
293                  If Not response = "OK" Then GoTo configError
294                  connected = True
295                  responseNumber = 0
296 <                Winsock2.Close
296 >                TCPSock.Close
297                  Text4.Text = Text4.Text & vbCrLf & "  <closed>"
298 <                x = MsgBox("got config okay")
298 >                Status.Caption = "Configuration successful"
299 >                Label3.Caption = UDPUpdateTime
300 >                Label4.Caption = TCPUpdateTime
301 >                Timer1.Interval = 1000
302          End Select
303      Else
304          ' Perform a heartbeat (1.1)
# Line 235 | Line 306 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
306          Select Case responseNumber
307              Case 1:
308                  If Not response = "OK" Then GoTo heartbeatError
309 <                Winsock2.SendData "CONFIG" & vbCrLf
309 >                TCPSock.SendData "CONFIG" & vbCrLf
310              Case 2:
311                  If Not response = "OK" Then GoTo heartbeatError
312 <                Winsock2.SendData fileList & vbCrLf
312 >                TCPSock.SendData fileList & vbCrLf
313              Case 3:
314                  If Not response = "OK" Then GoTo heartbeatError
315 <                Winsock2.SendData lastModified & vbCrLf
315 >                TCPSock.SendData lastModified & vbCrLf
316              Case 4:
317                  If Not response = "OK" Then GoTo heartbeatError
318 <                Winsock2.SendData "ENDHEARTBEAT" & vbCrLf
318 >                TCPSock.SendData "ENDHEARTBEAT" & vbCrLf
319              Case 5:
320                  If Not response = "OK" Then GoTo heartbeatError
321 <                Winsock2.Close
322 <                x = MsgBox("heartbeat sent okay.")
321 >                TCPSock.Close
322 >                Status.Caption = "Heartbeat sent successfully."
323          End Select
324      
325      End If
# Line 257 | Line 328 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
328      Exit Sub
329      
330   configError:
331 <    x = MsgBox("error doing configuration")
331 >    Status.Caption = "FAILED to get configuration"
332 >    Exit Sub
333   heartbeatError:
334 <    x = MsgBox("error doing configuration")
334 >    Status.Caption = "Heatbeat FAILED"
335 >    Exit Sub
336 > End Sub
337 >
338 > Private Sub Timer1_Timer()
339 >
340 >    Label3.Caption = Label3.Caption - 1
341 >    Label4.Caption = Label4.Caption - 1
342 >    
343 >    Status.Caption = ""
344 >    
345 >    If Label3.Caption < 1 Then
346 >        ' build the contents of the XML packet.
347 >        xml = "<packet></packet>"
348 >
349 >        ' Use the first winsock control to send a UDP packet.
350 >        UDPSock.RemoteHost = filterHostname
351 >        UDPSock.RemotePort = filterUDPPort
352 >        UDPSock.SendData xml
353 >        Status.Caption = "UDP packet sent"
354 >        Label3.Caption = UDPUpdateTime
355 >    End If
356 >    
357 >    If Label4.Caption < 1 Then
358 >        ' establish a TCP connection to a filter
359 >        TCPSock.Close
360 >        TCPSock.Connect filterHostname, filterTCPPort
361 >        Label4.Caption = TCPUpdateTime
362 >    End If
363 >
364   End Sub

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines