📄 frmclient.frm
字号:
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmClient
Caption = "Client"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
BeginProperty Font
Name = "Arial"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.ComboBox cboProtocol
Height = 345
ItemData = "frmClient.frx":0000
Left = 720
List = "frmClient.frx":000A
Style = 2 'Dropdown List
TabIndex = 8
Top = 120
Width = 1215
End
Begin VB.CommandButton cmdSend
Caption = "发消息"
Height = 495
Left = 3240
TabIndex = 7
Top = 2640
Width = 1215
End
Begin VB.TextBox txtMessage
Height = 330
Left = 120
TabIndex = 6
Text = "Text1"
Top = 2160
Width = 4335
End
Begin VB.TextBox txtIP
Height = 330
Left = 720
TabIndex = 5
Text = "127.0.0.1"
Top = 525
Width = 1215
End
Begin VB.TextBox txtPort
Height = 330
Left = 720
TabIndex = 2
Text = "61450"
Top = 960
Width = 1215
End
Begin VB.CommandButton cmdConnect
Caption = "连接"
Height = 495
Left = 240
TabIndex = 1
Top = 1440
Width = 1215
End
Begin VB.CommandButton cmdClose
Caption = "断开"
Enabled = 0 'False
Height = 495
Left = 1680
TabIndex = 0
Top = 1440
Width = 1215
End
Begin MSWinsockLib.Winsock wskClient
Left = 2760
Top = 840
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "协议:"
Height = 225
Left = 120
TabIndex = 9
Top = 180
Width = 540
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "IP:"
Height = 225
Left = 120
TabIndex = 4
Top = 600
Width = 345
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "端口:"
Height = 225
Left = 120
TabIndex = 3
Top = 1020
Width = 540
End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdClose_Click()
wskClient.Close '关闭连接和监听
cmdClose.Enabled = False
cmdConnect.Enabled = True
End Sub
Private Sub cmdConnect_Click()
wskClient.RemoteHost = txtIP.Text '设置服务器IP
wskClient.RemotePort = Val(txtPort.Text) '设置服务器端口
If (cboProtocol.ListIndex = 0) Then
wskClient.Protocol = sckTCPProtocol 'tcp
wskClient.Connect '连接服务器
Else
wskClient.Protocol = sckUDPProtocol 'udp 不需要连接
End If
cmdClose.Enabled = True
cmdConnect.Enabled = False
End Sub
Private Sub cmdSend_Click()
If (Len(txtMessage.Text) > 0) Then
wskClient.SendData txtMessage.Text '发送消息给服务器
End If
End Sub
Private Sub Form_Load()
cboProtocol.ListIndex = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -