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.6 by pjm2, Fri Feb 23 10:53:30 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        =   3
22        Top             =   2520
23        Width           =   1575
24     End
25     Begin VB.TextBox Text4
26 <      Height          =   2535
26 >      Height          =   1575
27        Left            =   240
28        MultiLine       =   -1  'True
29        ScrollBars      =   2  'Vertical
30 <      TabIndex        =   8
30 >      TabIndex        =   2
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        =   1
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
53        Left            =   4320
54 <      TabIndex        =   2
54 >      TabIndex        =   0
55        Top             =   1560
56        Width           =   975
57     End
58 <   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
58 >   Begin MSWinsockLib.Winsock UDPSock
59        Left            =   4320
60        Top             =   120
61        _ExtentX        =   741
# Line 87 | Line 63 | Begin VB.Form Form1
63        _Version        =   393216
64        Protocol        =   1
65     End
66 <   Begin VB.Label Label3
67 <      Alignment       =   1  'Right Justify
92 <      Caption         =   "Destination:"
66 >   Begin VB.Label Status
67 >      Caption         =   "Status:"
68        Height          =   255
69 <      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
69 >      Left            =   120
70        TabIndex        =   4
71 <      Top             =   1920
72 <      Width           =   1215
71 >      Top             =   5280
72 >      Width           =   5415
73     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
74   End
75   Attribute VB_Name = "Form1"
76   Attribute VB_GlobalNameSpace = False
77   Attribute VB_Creatable = False
78   Attribute VB_PredeclaredId = True
79   Attribute VB_Exposed = False
80 + 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
81 + 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
82 +
83 + Dim filterManagerHostname As String
84 + Dim filterManagerTCPPort As Integer
85 +
86 + Dim filterHostname As String
87 + Dim filterTCPPort As Integer
88 + Dim filterUDPPort As Integer
89 + Dim fileList As String
90 + Dim lastModified As String
91 +
92 + Dim protocolVersion As String
93 + Dim connected As Boolean
94   Dim responseNumber As Integer
95  
96  
97   Private Sub Command1_Click()
98  
99 <    ' Use the first winsock control to send
100 <    ' a UDP packet.
129 <    Winsock1.RemoteHost = Text3.Text
130 <    Winsock1.RemotePort = Text2.Text
131 <    Winsock1.SendData Text1.Text
99 >    ' build the contents of the XML packet.
100 >    xml = "<packet></packet>"
101  
102 +    ' Use the first winsock control to send a UDP packet.
103 +    UDPSock.RemoteHost = filterHostname
104 +    UDPSock.RemotePort = filterUDPPort
105 +    UDPSock.SendData xml
106 +    Status.Caption = "i-scream Winhost " & protocolVersion & " - UDP packet sent."
107 +
108   End Sub
109  
110   Private Sub Command2_Click()
111      
112 <    ' establish a TCP connection to a machine
113 <    Winsock2.Close
114 <    Winsock2.Connect Text3.Text, Text2.Text
112 >    ' establish a TCP connection to a filtermanager
113 >    TCPSock.Close
114 >    TCPSock.Connect filterManagerHostname, filterManagerTCPPort
115  
116   End Sub
117  
118   Private Sub Command3_Click()
119 <    x = MsgBox("not implemented..")
119 >    ' establish a TCP connection to a filter
120 >    TCPSock.Close
121 >    TCPSock.Connect filterHostname, filterTCPPort
122   End Sub
123  
124 < Private Sub Winsock2_Connect()
125 <      
126 <   responseNumber = 0
124 > Private Sub Form_Load()
125 >    protocolVersion = "1.1"
126 >    
127 >    Status.Caption = "i-scream Winhost " & protocolVersion
128 >    
129 >    ''''TEMP
130 >    filterManagerHostname = "killigrew.ukc.ac.uk"
131 >    filterManagerTCPPort = 4567
132 >    Exit Sub
133 >    ''' ENDTEMP
134 >    
135 >    On Error GoTo iniError
136 >    Dim buf As String * 256
137 >    Dim length As Long
138 >    length = GetPrivateProfileString("i-scream Winhost", "FilterManager", "<no value>", buf, Len(buf), App.Path & "winhost.ini")
139 >    filterManagerHostname = Left$(buf, length)
140 >    length = GetPrivateProfileString("i-scream Winhost", "FilterManagerPort", "<no value>", buf, Len(buf), App.Path & "winhost.ini")
141 >    filterManagerTCPPort = Left$(buf, length)
142 >    
143 >    Status.Caption = "i-scream Winhost " & protocolVersion & " connecting to Filter Manager"
144 >    
145 >    Exit Sub
146 >    
147 > iniError:
148 >    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")
149 >    End
150 >    
151 > End Sub
152 >
153 > Private Sub Label1_Click()
154 >
155 > End Sub
156 >
157 > Private Sub TCPSock_Connect()
158 >    
159 >    responseNumber = 0
160    
161 <   ' As soon as we are connected to the server, send this.
162 <   Winsock2.SendData "STARTCONFIG" & vbCrLf
161 >    ' Send something as soon as we connect to the server.
162 >    If connected = False Then
163 >        ' contact the FilterManager
164 >        TCPSock.SendData "STARTCONFIG" & vbCrLf
165 >    Else
166 >       ' Contact the Filter
167 >       TCPSock.SendData "HEARTBEAT" & vbCrLf
168 >    End If
169    
170   End Sub
171  
172 < Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
172 > Private Sub TCPSock_DataArrival(ByVal bytesTotal As Long)
173      
174      responseNumber = responseNumber + 1
175      
176      ' Get the line from the server.
177 <    Winsock2.GetData response, vbString, bytesTotal
177 >    TCPSock.GetData response, vbString, bytesTotal
178      
179      ' Remove linefeeds and returns from the line.
180      response = Replace(response, Chr(13), "")
181      response = Replace(response, Chr(10), "")
182      Text4.Text = Text4.Text & vbCrLf & response
183      
184 <    ' Decide what to send back to the server.
185 <    Select Case responseNumber
186 <        Case 1:
187 <            Winsock2.SendData "LASTMODIFIED" & vbCrLf
188 <        Case 2:
189 <            Winsock2.SendData "FILELIST" & vbCrLf
190 <        Case 3:
191 <            Winsock2.SendData "UDPUpdateTime" & vbCrLf
192 <        Case 4:
193 <            Winsock2.SendData "TCPUpdateTime" & vbCrLf
194 <        Case 5:
195 <            Winsock2.SendData "ENDCONFIG" & vbCrLf
196 <        Case 6:
197 <            Winsock2.SendData "FILTER" & vbCrLf
198 <        Case 7:
199 <            Winsock2.SendData "END" & vbCrLf
200 <        Case 8:
201 <            Winsock2.Close
202 <            Text4.Text = Text4.Text & vbCrLf & "  <closed>"
203 <    End Select
184 >    If connected = False Then
185 >        ' Perform TCP configuration (1.1)
186 >        On Error GoTo configError
187 >        Select Case responseNumber
188 >            Case 1:
189 >                If Not response = "OK" Then GoTo configError
190 >                TCPSock.SendData "LASTMODIFIED" & vbCrLf
191 >            Case 2:
192 >                If response = "ERROR" Then GoTo configError
193 >                lastModified = response
194 >                TCPSock.SendData "FILELIST" & vbCrLf
195 >            Case 3:
196 >                If response = "ERROR" Then GoTo configError
197 >                fileList = response
198 >                TCPSock.SendData "UDPUpdateTime" & vbCrLf
199 >            Case 4:
200 >                If response = "ERROR" Then GoTo configError
201 >                TCPSock.SendData "TCPUpdateTime" & vbCrLf
202 >            Case 5:
203 >                If response = "ERROR" Then GoTo configError
204 >                TCPSock.SendData "ENDCONFIG" & vbCrLf
205 >            Case 6:
206 >                If Not response = "OK" Then GoTo configError
207 >                TCPSock.SendData "FILTER" & vbCrLf
208 >            Case 7:
209 >                'we got a filter list here.
210 >                readTo = 0
211 >                ' get hostname
212 >                readTo = InStr(1, response, ";", vbBinaryCompare)
213 >                filterHostname = Mid(response, 1, readTo - 1)
214 >                response = Mid(response, readTo + 1, Len(response))
215 >                ' get UDP Port number
216 >                readTo = InStr(1, response, ";")
217 >                filterUDPPort = Mid(response, 1, readTo - 1)
218 >                response = Mid(response, readTo + 1, Len(response))
219 >                ' get TCP Port number
220 >                filterTCPPort = response
221 >                TCPSock.SendData "END" & vbCrLf
222 >            Case 8:
223 >                If Not response = "OK" Then GoTo configError
224 >                connected = True
225 >                responseNumber = 0
226 >                TCPSock.Close
227 >                Text4.Text = Text4.Text & vbCrLf & "  <closed>"
228 >                Status.Caption = "i-scream Winhost " & protocolVersion & " - got config okay"
229 >        End Select
230 >    Else
231 >        ' Perform a heartbeat (1.1)
232 >        On Error GoTo heartbeatError
233 >        Select Case responseNumber
234 >            Case 1:
235 >                If Not response = "OK" Then GoTo heartbeatError
236 >                TCPSock.SendData "CONFIG" & vbCrLf
237 >            Case 2:
238 >                If Not response = "OK" Then GoTo heartbeatError
239 >                TCPSock.SendData fileList & vbCrLf
240 >            Case 3:
241 >                If Not response = "OK" Then GoTo heartbeatError
242 >                TCPSock.SendData lastModified & vbCrLf
243 >            Case 4:
244 >                If Not response = "OK" Then GoTo heartbeatError
245 >                TCPSock.SendData "ENDHEARTBEAT" & vbCrLf
246 >            Case 5:
247 >                If Not response = "OK" Then GoTo heartbeatError
248 >                TCPSock.Close
249 >                Status.Caption = "i-scream Winhost " & protocolVersion & " - heartbeat sent okay."
250 >        End Select
251      
252 +    End If
253 +    
254 +    
255 +    Exit Sub
256 +    
257 + configError:
258 +    Status.Caption = "i-scream Winhost " & protocolVersion & " - FAILED to get configuration"
259 + heartbeatError:
260 +    Status.Caption = "i-scream Winhost " & protocolVersion & " - Heatbeat FAILED"
261   End Sub
262 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines