ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/host/vb_net_test/nettest.frm
Revision: 1.1
Committed: Thu Feb 22 17:04:22 2001 UTC (23 years, 9 months ago) by pjm2
Branch: MAIN
Log Message:
A basic test of some network functions in Visual Basic for Windows.
These use the mswinsck.ocx ActiveX component.
These should be runnable on most Win32 platforms with the Visual Basic 6
runtime installed (available from the microsoft website)

File Contents

# User Rev Content
1 pjm2 1.1 VERSION 5.00
2     Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
3     Begin VB.Form Form1
4     BorderStyle = 3 'Fixed Dialog
5     Caption = "TCP/UDP Test program"
6     ClientHeight = 5655
7     ClientLeft = 45
8     ClientTop = 330
9     ClientWidth = 5670
10     LinkTopic = "Form1"
11     MaxButton = 0 'False
12     MinButton = 0 'False
13     ScaleHeight = 5655
14     ScaleWidth = 5670
15     ShowInTaskbar = 0 'False
16     StartUpPosition = 3 'Windows Default
17     Begin VB.CommandButton Command3
18     Caption = "TCP to Filter"
19     Height = 375
20     Left = 3720
21     TabIndex = 9
22     Top = 2520
23     Width = 1575
24     End
25     Begin VB.TextBox Text4
26     Height = 2535
27     Left = 240
28     MultiLine = -1 'True
29     ScrollBars = 2 'Vertical
30     TabIndex = 8
31     Text = "nettest.frx":0000
32     Top = 3000
33     Width = 5055
34     End
35     Begin VB.CommandButton Command2
36     Caption = "TCP to FilterManager"
37     Height = 375
38     Left = 3360
39     TabIndex = 7
40     Top = 2040
41     Width = 1935
42     End
43     Begin MSWinsockLib.Winsock Winsock2
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
66     Begin VB.CommandButton Command1
67     Caption = "Send UDP"
68     Height = 375
69     Left = 4320
70     TabIndex = 2
71     Top = 1560
72     Width = 975
73     End
74     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
83     Left = 4320
84     Top = 120
85     _ExtentX = 741
86     _ExtentY = 741
87     _Version = 393216
88     Protocol = 1
89     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
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
116     End
117     Attribute VB_Name = "Form1"
118     Attribute VB_GlobalNameSpace = False
119     Attribute VB_Creatable = False
120     Attribute VB_PredeclaredId = True
121     Attribute VB_Exposed = False
122     Dim responseNumber As Integer
123    
124    
125     Private Sub Command1_Click()
126    
127     ' Use the first winsock control to send
128     ' a UDP packet.
129     Winsock1.RemoteHost = Text3.Text
130     Winsock1.RemotePort = Text2.Text
131     Winsock1.SendData Text1.Text
132    
133     End Sub
134    
135     Private Sub Command2_Click()
136    
137     ' establish a TCP connection to a machine
138     Winsock2.Close
139     Winsock2.Connect Text3.Text, Text2.Text
140    
141     End Sub
142    
143     Private Sub Command3_Click()
144     x = MsgBox("not implemented..")
145     End Sub
146    
147     Private Sub Winsock2_Connect()
148    
149     responseNumber = 0
150    
151     ' As soon as we are connected to the server, send this.
152     Winsock2.SendData "STARTCONFIG" & vbCrLf
153    
154     End Sub
155    
156     Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
157    
158     responseNumber = responseNumber + 1
159    
160     ' Get the line from the server.
161     Winsock2.GetData response, vbString, bytesTotal
162    
163     ' Remove linefeeds and returns from the line.
164     response = Replace(response, Chr(13), "")
165     response = Replace(response, Chr(10), "")
166     Text4.Text = Text4.Text & vbCrLf & response
167    
168     ' Decide what to send back to the server.
169     Select Case responseNumber
170     Case 1:
171     Winsock2.SendData "LASTMODIFIED" & vbCrLf
172     Case 2:
173     Winsock2.SendData "FILELIST" & vbCrLf
174     Case 3:
175     Winsock2.SendData "UDPUpdateTime" & vbCrLf
176     Case 4:
177     Winsock2.SendData "TCPUpdateTime" & vbCrLf
178     Case 5:
179     Winsock2.SendData "ENDCONFIG" & vbCrLf
180     Case 6:
181     Winsock2.SendData "FILTER" & vbCrLf
182     Case 7:
183     Winsock2.SendData "END" & vbCrLf
184     Case 8:
185     Winsock2.Close
186     Text4.Text = Text4.Text & vbCrLf & " <closed>"
187     End Select
188    
189     End Sub