📄 frmtest.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmTest
Caption = "Test Application"
ClientHeight = 1545
ClientLeft = 60
ClientTop = 345
ClientWidth = 3090
LinkTopic = "Form1"
ScaleHeight = 1545
ScaleWidth = 3090
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdTerminate
Caption = "Terminate"
Height = 375
Left = 1560
TabIndex = 5
Top = 960
Width = 1335
End
Begin VB.CommandButton cmdExecute
Caption = "Execute"
Height = 375
Left = 120
TabIndex = 4
Top = 960
Width = 1335
End
Begin VB.TextBox txtPort
Height = 285
Left = 720
TabIndex = 3
Text = "4000"
Top = 600
Width = 495
End
Begin VB.TextBox txtHost
Height = 285
Left = 720
TabIndex = 1
Text = "127.0.0.1"
Top = 120
Width = 1335
End
Begin MSWinsockLib.Winsock sckTest
Index = 0
Left = 1560
Top = 480
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Label lblPort
Caption = "Port"
Height = 255
Left = 120
TabIndex = 2
Top = 600
Width = 375
End
Begin VB.Label lblHost
Caption = "Host"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 495
End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Written by Jason E. Robinson
'Started 11/25/2004
'Last updated 05/02/2007
'Server Socket Processor to provide server side TCP communications.
' Copyright 2007 Jason E. Robinson
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
' http://www.apache.org/licenses/LICENSE-2.0
' Unless required by applicable law or agreed to in writing, software
' distributed under the License is distributed on an "AS IS" BASIS,
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' See the License for the specific language governing permissions and
' limitations under the License.
Option Explicit
Dim bRun As Boolean
Private Sub cmdExecute_Click()
Dim lngLoop As Long
Dim strTest As String
bRun = True
For lngLoop = 1 To 50
Load sckTest(lngLoop)
DoEvents
sckTest(lngLoop).RemoteHost = txtHost.Text
sckTest(lngLoop).RemotePort = CInt(txtPort.Text)
sckTest(lngLoop).Connect
Next lngLoop
Do While bRun
For lngLoop = 1 To 50
strTest = Chr(Int(Rnd * 255))
DoEvents
If sckTest(lngLoop).State = sckConnected Then
sckTest(lngLoop).SendData (strTest)
End If
strTest = ""
Next lngLoop
Loop
End Sub
Private Sub cmdTerminate_Click()
Dim lngLoop As Long
bRun = False
For lngLoop = 1 To 50
sckTest(lngLoop).Close
Unload sckTest(lngLoop)
Next
End Sub
Private Sub Form_Load()
bRun = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -