程序用的VB(或EXCEL的VBA)语言,Winsock控件
Private Sub Form_Load()
Winsock1.LocalPort = 8423 '设置侦听端口
Winsock1.Listen '侦听
End Sub
Private Sub Winsock1_connectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then
Winsock1.Close
Winsock1.Accept requestID
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Winsock1.GetData strData '接收到信息后在文本框显示
Text2.Text = strData
End Sub
Private Sub Command1_Click()
Winsock1.SendData "$AFSTATUS,W*hh" & vbCrLf '发送$AFSTATUS,W*hh<CR><LF>命令,,,回车换行的字符串在VB中是VBCRLF
End Sub