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.3 by pjm2, Fri Feb 23 10:07:55 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
# Line 132 | Line 96 | Dim responseNumber As Integer
96  
97   Private Sub Command1_Click()
98  
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 <    Winsock1.RemoteHost = Text3.Text
104 <    Winsock1.RemotePort = Text2.Text
105 <    Winsock1.SendData Text1.Text
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 filtermanager
113 <    Winsock2.Close
114 <    Winsock2.Connect Text3.Text, Text2.Text
113 >    TCPSock.Close
114 >    TCPSock.Connect filterManagerHostname, filterManagerTCPPort
115  
116   End Sub
117  
118   Private Sub Command3_Click()
119      ' establish a TCP connection to a filter
120 <    Winsock2.Close
121 <    Winsock2.Connect filterHostname, filterTCPPort
120 >    TCPSock.Close
121 >    TCPSock.Connect filterHostname, filterTCPPort
122   End Sub
123  
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 Winsock2_Connect()
154 <      
155 <   responseNumber = 0
153 > Private Sub Label1_Click()
154 >
155 > End Sub
156 >
157 > Private Sub TCPSock_Connect()
158 >    
159 >    responseNumber = 0
160    
161      ' Send something as soon as we connect to the server.
162      If connected = False Then
163          ' contact the FilterManager
164 <        Winsock2.SendData "STARTCONFIG" & vbCrLf
164 >        TCPSock.SendData "STARTCONFIG" & vbCrLf
165      Else
166         ' Contact the Filter
167 <       Winsock2.SendData "HEARTBEAT" & vbCrLf
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), "")
# Line 190 | Line 187 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
187          Select Case responseNumber
188              Case 1:
189                  If Not response = "OK" Then GoTo configError
190 <                Winsock2.SendData "LASTMODIFIED" & vbCrLf
190 >                TCPSock.SendData "LASTMODIFIED" & vbCrLf
191              Case 2:
192                  If response = "ERROR" Then GoTo configError
193                  lastModified = response
194 <                Winsock2.SendData "FILELIST" & vbCrLf
194 >                TCPSock.SendData "FILELIST" & vbCrLf
195              Case 3:
196                  If response = "ERROR" Then GoTo configError
197                  fileList = response
198 <                Winsock2.SendData "UDPUpdateTime" & vbCrLf
198 >                TCPSock.SendData "UDPUpdateTime" & vbCrLf
199              Case 4:
200                  If response = "ERROR" Then GoTo configError
201 <                Winsock2.SendData "TCPUpdateTime" & vbCrLf
201 >                TCPSock.SendData "TCPUpdateTime" & vbCrLf
202              Case 5:
203                  If response = "ERROR" Then GoTo configError
204 <                Winsock2.SendData "ENDCONFIG" & vbCrLf
204 >                TCPSock.SendData "ENDCONFIG" & vbCrLf
205              Case 6:
206                  If Not response = "OK" Then GoTo configError
207 <                Winsock2.SendData "FILTER" & vbCrLf
207 >                TCPSock.SendData "FILTER" & vbCrLf
208              Case 7:
209                  'we got a filter list here.
210                  readTo = 0
# Line 221 | Line 218 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
218                  response = Mid(response, readTo + 1, Len(response))
219                  ' get TCP Port number
220                  filterTCPPort = response
221 <                Winsock2.SendData "END" & vbCrLf
221 >                TCPSock.SendData "END" & vbCrLf
222              Case 8:
223                  If Not response = "OK" Then GoTo configError
224                  connected = True
225                  responseNumber = 0
226 <                Winsock2.Close
226 >                TCPSock.Close
227                  Text4.Text = Text4.Text & vbCrLf & "  <closed>"
228 <                x = MsgBox("got config okay")
228 >                Status.Caption = "i-scream Winhost " & protocolVersion & " - got config okay"
229          End Select
230      Else
231          ' Perform a heartbeat (1.1)
# Line 236 | Line 233 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
233          Select Case responseNumber
234              Case 1:
235                  If Not response = "OK" Then GoTo heartbeatError
236 <                Winsock2.SendData "CONFIG" & vbCrLf
236 >                TCPSock.SendData "CONFIG" & vbCrLf
237              Case 2:
238                  If Not response = "OK" Then GoTo heartbeatError
239 <                Winsock2.SendData fileList & vbCrLf
239 >                TCPSock.SendData fileList & vbCrLf
240              Case 3:
241                  If Not response = "OK" Then GoTo heartbeatError
242 <                Winsock2.SendData lastModified & vbCrLf
242 >                TCPSock.SendData lastModified & vbCrLf
243              Case 4:
244                  If Not response = "OK" Then GoTo heartbeatError
245 <                Winsock2.SendData "ENDHEARTBEAT" & vbCrLf
245 >                TCPSock.SendData "ENDHEARTBEAT" & vbCrLf
246              Case 5:
247                  If Not response = "OK" Then GoTo heartbeatError
248 <                Winsock2.Close
249 <                x = MsgBox("heartbeat sent okay.")
248 >                TCPSock.Close
249 >                Status.Caption = "i-scream Winhost " & protocolVersion & " - heartbeat sent okay."
250          End Select
251      
252      End If
# Line 258 | Line 255 | Private Sub Winsock2_DataArrival(ByVal bytesTotal As L
255      Exit Sub
256      
257   configError:
258 <    x = MsgBox("error doing configuration")
258 >    Status.Caption = "i-scream Winhost " & protocolVersion & " - FAILED to get configuration"
259   heartbeatError:
260 <    
260 >    Status.Caption = "i-scream Winhost " & protocolVersion & " - Heatbeat FAILED"
261   End Sub
262 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines