📄 服务器端代码清单.txt
字号:
Private intmax As Integer '定义联入线的最大值
Private Sub Command1_Click()
txtreceive.Text = ""
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
intmax = 15
For i = 1 To intmax - 1
Load sckServer(i)
Next i
sckListen.LocalPort = 1011
sckListen.Listen
'显示主机IP地址
Label2.Caption = sckListen.LocalIP
End Sub
Private Sub sckBusy_Close()
sckBusy.Close
End Sub
Private Sub sckBusy_DataArrival(ByVal bytesTotal As Long)
sckBusy.SendData "服务器忙,请稍后再连接!"
DoEvents
End Sub
Private Sub sckListen_ConnectionRequest(ByVal requestID As Long)
Dim i As Integer
'决定由哪一Winsock接受请求
For i = 0 To intmax - 1
If sckServer(i).State = sckClosed Then
Exit For
End If
Next i
If sckServer(i).State = sckClosed Then
sckServer(i).Accept requestID
Exit Sub
End If
'如果所有Winsock都用完则由专门的“忙”Winsock接受请求,以免用户要求得不到响应
sckBusy.Close
sckBusy.Accept requestID
End Sub
Private Sub sckListen_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
sckListen.Close
sckListen.LocalPort = 1011
sckListen.Listen
End Sub
Private Sub sckServer_Close(Index As Integer)
sckServer(Index).Close
End Sub
Private Sub sckServer_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim s As String
Dim i As Integer
sckServer(Index).GetData s
For i = 0 To intmax - 1
If sckServer(i).State = sckConnected Then
sckServer(i).SendData Trim(s)
DoEvents
End If
Next i
txtreceive.Text = txtreceive.Text + Chr$(13) + Chr$(10) + Trim(s)
End Sub
Private Sub sckServer_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
sckServer(Index).Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -