这是服务器端的:Private Sub tcpServer_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpServer.GetData strData
txtOutput.Text = strData
End Sub
Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long)
If tcpServer.State <> sckClosed Then
tcpServer.Close
tcpServer.Accept requestID
End If
End Sub
Private Sub Form_Load()
tcpServer.LocalPort = 1001
tcpServer.Listen
frmClient.Show '显示客户端的窗体。
End Sub
Private Sub txtSendData_Change()
tcpServer.SendData txtSendData.Text
End Sub
这是客户端的:
Private Sub cmdConnect_Click()
tcpClient.Connect
End Sub
Private Sub Form_Load()
tcpClient.RemoteHost = tcpClient.LocalHostName
tcpClient.RemotePort = 1001
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
tcpClient.GetData strData
txtOutput.Text = strData
End Sub
Private Sub txtSend_Change()
tcpClient.SendData txtSend.Text
End Sub