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

Comparing projects/cms/source/host/winhost/nettest.frm (file contents):
Revision 1.2 by pjm2, Fri Feb 23 09:42:36 2001 UTC vs.
Revision 1.5 by pjm2, Fri Feb 23 10:34:47 2001 UTC

# Line 18 | Line 18 | Begin VB.Form Form1
18        Caption         =   "TCP to Filter"
19        Height          =   375
20        Left            =   3720
21 <      TabIndex        =   9
21 >      TabIndex        =   5
22        Top             =   2520
23        Width           =   1575
24     End
# Line 27 | Line 27 | Begin VB.Form Form1
27        Left            =   240
28        MultiLine       =   -1  'True
29        ScrollBars      =   2  'Vertical
30 <      TabIndex        =   8
30 >      TabIndex        =   4
31        Text            =   "nettest.frx":0000
32        Top             =   3000
33        Width           =   5055
# Line 36 | Line 36 | Begin VB.Form Form1
36        Caption         =   "TCP to FilterManager"
37        Height          =   375
38        Left            =   3360
39 <      TabIndex        =   7
39 >      TabIndex        =   3
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
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
50     Begin VB.CommandButton Command1
51        Caption         =   "Send UDP"
52        Height          =   375
# Line 79 | Line 63 | Begin VB.Form Form1
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
# Line 87 | Line 71 | Begin VB.Form Form1
71        _Version        =   393216
72        Protocol        =   1
73     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
74     Begin VB.Label Label1
75        Caption         =   "Packet contents"
76        Height          =   255
# Line 119 | Line 85 | Attribute VB_GlobalNameSpace = False
85   Attribute VB_Creatable = False
86   Attribute VB_PredeclaredId = True
87   Attribute VB_Exposed = False
88 + Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
89 + Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
90 +
91 + Dim filterManagerHostname As String
92 + Dim filterManagerTCPPort As Integer
93 +
94   Dim filterHostname As String
95 < Dim filterTCPPort As String
96 < Dim filterUDPPort As String
95 > Dim filterTCPPort As Integer
96 > Dim filterUDPPort As Integer
97 > Dim fileList As String
98 > Dim lastModified As String
99  
100   Dim protocolVersion As String
101   Dim connected As Boolean
# Line 130 | Line 104 | Dim responseNumber As Integer
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 = Text3.Text
112 <    Winsock1.RemotePort = Text2.Text
113 <    Winsock1.SendData Text1.Text
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 machine
120 <    Winsock2.Close
121 <    Winsock2.Connect Text3.Text, Text2.Text
119 >    ' establish a TCP connection to a filtermanager
120 >    TCPSock.Close
121 >    TCPSock.Connect filterManagerHostname, filterManagerTCPPort
122  
123   End Sub
124  
125   Private Sub Command3_Click()
126 <    x = MsgBox("not implemented..")
126 >    ' establish a TCP connection to a filter
127 >    TCPSock.Close
128 >    TCPSock.Connect filterHostname, filterTCPPort
129   End Sub
130  
131   Private Sub Form_Load()
132      protocolVersion = "1.1"
133 +    
134 +    ''''TEMP
135 +    filterManagerHostname = "killigrew.ukc.ac.uk"
136 +    filterManagerTCPPort = 4567
137 +    Exit Sub
138 +    ''' ENDTEMP
139 +    
140 +    On Error GoTo iniError
141 +    Dim buf As String * 256
142 +    Dim length As Long
143 +    length = GetPrivateProfileString("i-scream Winhost", "FilterManager", "<no value>", buf, Len(buf), App.Path & "winhost.ini")
144 +    filterManagerHostname = Left$(buf, length)
145 +    length = GetPrivateProfileString("i-scream Winhost", "FilterManagerPort", "<no value>", buf, Len(buf), App.Path & "winhost.ini")
146 +    filterManagerTCPPort = Left$(buf, length)
147 +    
148 +    Exit Sub
149 +    
150 + iniError:
151 +    x = MsgBox("The i-scream Winhost could not read the correct settings from the winhost.ini file.  Please correct these and try again.", 48, "Configuration not found")
152 +    End
153 +    
154   End Sub
155  
156 < Private Sub Winsock2_Connect()
156 > Private Sub TCPSock_Connect()
157        
158     responseNumber = 0
159    
160 <   ' As soon as we are connected to the server, send this.
161 <   Winsock2.SendData "STARTCONFIG" & vbCrLf
160 >    ' Send something as soon as we connect to the server.
161 >    If connected = False Then
162 >        ' contact the FilterManager
163 >        TCPSock.SendData "STARTCONFIG" & vbCrLf
164 >    Else
165 >       ' Contact the Filter
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), "")
# Line 180 | Line 186 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
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 <                Winsock2.SendData "FILELIST" & vbCrLf
192 >                lastModified = response
193 >                TCPSock.SendData "FILELIST" & vbCrLf
194              Case 3:
195                  If response = "ERROR" Then GoTo configError
196 <                Winsock2.SendData "UDPUpdateTime" & vbCrLf
196 >                fileList = response
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
# Line 209 | Line 217 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
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
# Line 223 | Line 231 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
231          On Error GoTo heartbeatError
232          Select Case responseNumber
233              Case 1:
234 <                
234 >                If Not response = "OK" Then GoTo heartbeatError
235 >                TCPSock.SendData "CONFIG" & vbCrLf
236              Case 2:
237 <                
237 >                If Not response = "OK" Then GoTo heartbeatError
238 >                TCPSock.SendData fileList & vbCrLf
239              Case 3:
240 <                
240 >                If Not response = "OK" Then GoTo heartbeatError
241 >                TCPSock.SendData lastModified & vbCrLf
242              Case 4:
243 <                
243 >                If Not response = "OK" Then GoTo heartbeatError
244 >                TCPSock.SendData "ENDHEARTBEAT" & vbCrLf
245              Case 5:
246 <                
247 <            Case 6:
248 <                
237 <            Case 7:
238 <                
239 <            Case 8:
240 <                
246 >                If Not response = "OK" Then GoTo heartbeatError
247 >                TCPSock.Close
248 >                x = MsgBox("heartbeat sent okay.")
249          End Select
250      
251      End If
# Line 248 | Line 256 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
256   configError:
257      x = MsgBox("error doing configuration")
258   heartbeatError:
259 <    
259 >    x = MsgBox("error doing configuration")
260   End Sub
261 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines