Private Sub TcpSever—ConnectionRequest(Index As Integer, ByVal requestID As Long)
If Index=0 Then
′生成新的WinSock控件响应客户端的请求
WSockIndex=WSockIndex+1
Load TcpSever(WSockIndex)
TcpSever(WSockIndex).LocalPort=0
′检查控件的 State 属性是否为关闭的。如果不是,在接受新的连接之前先关闭此连接
If TcpSever(WSockIndex).State〈〉sckClosed Then
TcpSever(WSockIndex).Close
End If
′接受具有requestID参数的连接
TcpSever(WSockIndex).Accept requestID
′为新的连接设立双向数据传输的TextBox
If WSockIndex>1 Then
Load TextSend(WSockIndex-1)
TextSend(WSockIndex-1).Left=TextSend(0).Left+(20+TextSend(0).Width)?(WSockIndex-1)
Load TextReceive(WSockIndex-1)
TextReceive(WSockIndex-1).Left=TextRecieve(0).Left+(20+TextReceive(0).Width)?(WSockIndex-1)
TextSend(WSockIndex-1).Visible=True
TextReceive(WSockIndex-1).Visible=True
End If
End If
End Sub