有个高人给我以下代码好象可以(不过我没实现过,也没弄懂,希望有高人可以解释一下):'初始化UDP winsock插件 Private Sub Form_Load() With UDPPeerA .RemoteHost = "127.0.0.1" '要连接到的计算机名 .RemotePort = 1010 '要连接到的端口号 .LocalPort = 1011 '该Winsock控制将要使用的本地端口号,便于其它端与该Winsock通讯 .Bind 1011 '将该Winsock控制绑定到该本地端口 End With End Sub '遇到回车发送信息 Private Sub txtSend_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then UDPPeerA.SendData txtSend.Text '发送文本 End If End Sub'接收信息 Private Sub udpPeerA_DataArrival(ByVal bytesTotal As Long) Dim strData As String UDPPeerA.GetData strData, vbString txtOutput.Text = txtOutput.Text & strData End Sub
---------------------------
请问是Active组件吗?一般用什么编写呢?C++吗?
能详细解释一下吗?
Private Sub Form_Load()
With UDPPeerA
.RemoteHost = "127.0.0.1" '要连接到的计算机名
.RemotePort = 1010 '要连接到的端口号
.LocalPort = 1011 '该Winsock控制将要使用的本地端口号,便于其它端与该Winsock通讯
.Bind 1011 '将该Winsock控制绑定到该本地端口
End With
End Sub
'遇到回车发送信息
Private Sub txtSend_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UDPPeerA.SendData txtSend.Text '发送文本
End If
End Sub'接收信息
Private Sub udpPeerA_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
UDPPeerA.GetData strData, vbString
txtOutput.Text = txtOutput.Text & strData
End Sub
你可以到到http://www.codeproject.com/去下载代码来看看到底是怎么实现的。
VC区和C#区比较多。