另一控件 fiveserver
Option ExplicitPublic HostIp As String
Public HostPort As String
'服务器启动的时间
Dim StartTime As Date
'登录到服务器的玩家人数
Dim VisitNum As Integer
'定义可登录的最大玩家数
Const MaxConnect = 20
'定义记录已经加载的winsock控件数
Dim WsockNum As Integer
'定义存储玩家信息的数组
Dim mUser(MaxConnect) As userInfo
'定义存储棋局信息的数组
Dim mtwoUser(MaxConnect / 2) As twoUser
Private Sub TcpWsock_ConnectionRequest(ByVal requestID As Long)
Dim i As Long
i = 1
Dim free As Boolean
free = False
'wsocknum为目前已经加载的winsock的数目
'在已经加载的控件数组中检查没有链接的控件
For i = 1 To WsockNum
If Wsock(i).State = sckClosed Then
free = True
Exit For
End If
Next i
'MaxConnect为最大连接数,如果已经加载的winsock控件达到最大,退出
If WsockNum = MaxConnect And free = False Then
Exit Sub
End If
'如果所有已经加载的winsock控件都在连接,加载新的控件
If free = False Then
'wsock(i)为控件数组
WsockNum = WsockNum + 1
Load Wsock(WsockNum)
i = WsockNum
End If
If Wsock(i).State <> sckClosed Then
Wsock(i).Close
End If
Wsock(i).Accept requestID
Wsock(i).SendData "/LgOn你已经连上BusyAnts的五子棋服务器了"
'保存玩家的上站时间、ip地址
mUser(i).mLogonTime = Now()
'登录到服务器的玩家人数+1
VisitNum = VisitNum + 1
mUser(i).muserIP = Wsock(i).RemoteHostIP
mUser(i).mConnected = True
End Sub
Private Sub txtTalk_Change()
If Len(txtTalk.Text) > 1000 Then
txtTalk.Text = ""
End If
End Sub
Private Sub UserControl_Initialize()
补充:asp教程,高级应用