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.1 by pjm2, Thu Feb 22 17:04:22 2001 UTC vs.
Revision 1.3 by pjm2, Fri Feb 23 10:07:55 2001 UTC

# Line 119 | Line 119 | 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 Integer
124 + Dim filterUDPPort As Integer
125 + Dim fileList As String
126 + Dim lastModified As String
127 +
128 + Dim protocolVersion As String
129 + Dim connected As Boolean
130   Dim responseNumber As Integer
131  
132  
133   Private Sub Command1_Click()
134  
135 <    ' Use the first winsock control to send
128 <    ' a UDP packet.
135 >    ' Use the first winsock control to send a UDP packet.
136      Winsock1.RemoteHost = Text3.Text
137      Winsock1.RemotePort = Text2.Text
138      Winsock1.SendData Text1.Text
# Line 134 | Line 141 | End Sub
141  
142   Private Sub Command2_Click()
143      
144 <    ' establish a TCP connection to a machine
144 >    ' establish a TCP connection to a filtermanager
145      Winsock2.Close
146      Winsock2.Connect Text3.Text, Text2.Text
147  
148   End Sub
149  
150   Private Sub Command3_Click()
151 <    x = MsgBox("not implemented..")
151 >    ' establish a TCP connection to a filter
152 >    Winsock2.Close
153 >    Winsock2.Connect filterHostname, filterTCPPort
154   End Sub
155  
156 + Private Sub Form_Load()
157 +    protocolVersion = "1.1"
158 + End Sub
159 +
160   Private Sub Winsock2_Connect()
161        
162     responseNumber = 0
163    
164 <   ' As soon as we are connected to the server, send this.
165 <   Winsock2.SendData "STARTCONFIG" & vbCrLf
164 >    ' Send something as soon as we connect to the server.
165 >    If connected = False Then
166 >        ' contact the FilterManager
167 >        Winsock2.SendData "STARTCONFIG" & vbCrLf
168 >    Else
169 >       ' Contact the Filter
170 >       Winsock2.SendData "HEARTBEAT" & vbCrLf
171 >    End If
172    
173   End Sub
174  
# Line 165 | Line 184 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
184      response = Replace(response, Chr(10), "")
185      Text4.Text = Text4.Text & vbCrLf & response
186      
187 <    ' Decide what to send back to the server.
188 <    Select Case responseNumber
189 <        Case 1:
190 <            Winsock2.SendData "LASTMODIFIED" & vbCrLf
191 <        Case 2:
192 <            Winsock2.SendData "FILELIST" & vbCrLf
193 <        Case 3:
194 <            Winsock2.SendData "UDPUpdateTime" & vbCrLf
195 <        Case 4:
196 <            Winsock2.SendData "TCPUpdateTime" & vbCrLf
197 <        Case 5:
198 <            Winsock2.SendData "ENDCONFIG" & vbCrLf
199 <        Case 6:
200 <            Winsock2.SendData "FILTER" & vbCrLf
201 <        Case 7:
202 <            Winsock2.SendData "END" & vbCrLf
203 <        Case 8:
204 <            Winsock2.Close
205 <            Text4.Text = Text4.Text & vbCrLf & "  <closed>"
206 <    End Select
187 >    If connected = False Then
188 >        ' Perform TCP configuration (1.1)
189 >        On Error GoTo configError
190 >        Select Case responseNumber
191 >            Case 1:
192 >                If Not response = "OK" Then GoTo configError
193 >                Winsock2.SendData "LASTMODIFIED" & vbCrLf
194 >            Case 2:
195 >                If response = "ERROR" Then GoTo configError
196 >                lastModified = response
197 >                Winsock2.SendData "FILELIST" & vbCrLf
198 >            Case 3:
199 >                If response = "ERROR" Then GoTo configError
200 >                fileList = response
201 >                Winsock2.SendData "UDPUpdateTime" & vbCrLf
202 >            Case 4:
203 >                If response = "ERROR" Then GoTo configError
204 >                Winsock2.SendData "TCPUpdateTime" & vbCrLf
205 >            Case 5:
206 >                If response = "ERROR" Then GoTo configError
207 >                Winsock2.SendData "ENDCONFIG" & vbCrLf
208 >            Case 6:
209 >                If Not response = "OK" Then GoTo configError
210 >                Winsock2.SendData "FILTER" & vbCrLf
211 >            Case 7:
212 >                'we got a filter list here.
213 >                readTo = 0
214 >                ' get hostname
215 >                readTo = InStr(1, response, ";", vbBinaryCompare)
216 >                filterHostname = Mid(response, 1, readTo - 1)
217 >                response = Mid(response, readTo + 1, Len(response))
218 >                ' get UDP Port number
219 >                readTo = InStr(1, response, ";")
220 >                filterUDPPort = Mid(response, 1, readTo - 1)
221 >                response = Mid(response, readTo + 1, Len(response))
222 >                ' get TCP Port number
223 >                filterTCPPort = response
224 >                Winsock2.SendData "END" & vbCrLf
225 >            Case 8:
226 >                If Not response = "OK" Then GoTo configError
227 >                connected = True
228 >                responseNumber = 0
229 >                Winsock2.Close
230 >                Text4.Text = Text4.Text & vbCrLf & "  <closed>"
231 >                x = MsgBox("got config okay")
232 >        End Select
233 >    Else
234 >        ' Perform a heartbeat (1.1)
235 >        On Error GoTo heartbeatError
236 >        Select Case responseNumber
237 >            Case 1:
238 >                If Not response = "OK" Then GoTo heartbeatError
239 >                Winsock2.SendData "CONFIG" & vbCrLf
240 >            Case 2:
241 >                If Not response = "OK" Then GoTo heartbeatError
242 >                Winsock2.SendData fileList & vbCrLf
243 >            Case 3:
244 >                If Not response = "OK" Then GoTo heartbeatError
245 >                Winsock2.SendData lastModified & vbCrLf
246 >            Case 4:
247 >                If Not response = "OK" Then GoTo heartbeatError
248 >                Winsock2.SendData "ENDHEARTBEAT" & vbCrLf
249 >            Case 5:
250 >                If Not response = "OK" Then GoTo heartbeatError
251 >                Winsock2.Close
252 >                x = MsgBox("heartbeat sent okay.")
253 >        End Select
254 >    
255 >    End If
256 >    
257 >    
258 >    Exit Sub
259 >    
260 > configError:
261 >    x = MsgBox("error doing configuration")
262 > heartbeatError:
263      
264   End Sub

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines