Private Sub cmdSend_Click()
Winsock1.SendData txtSend.Text
End SubPrivate Sub Form_Load()
Dim my As String
Winsock1.Protocol = sckUDPProtocol '设置为UDP协义
Winsock1.LocalPort = 5678
Winsock1.RemotePort = 1234Winsock1.RemoteHost = "192.168.0.244"
End SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '取得数据时发生
Dim Tmp As String
Winsock1.GetData Tmp, vbString '取得数据
Tmp = "对方位址:" + Winsock1.RemoteHostIP + "发言内容为-->" + Tmp
txtMess.Text = Tmp + Chr$(13) + Chr$(10) + txtMess.Text
End Sub
只要一按cmdSend就会出现:
Run-time error '10054': The Connection is reset by remote side
Winsock1.SendData txtSend.Text
End SubPrivate Sub Form_Load()
Dim my As String
Winsock1.Protocol = sckUDPProtocol '设置为UDP协义
Winsock1.LocalPort = 5678
Winsock1.RemotePort = 1234Winsock1.RemoteHost = "192.168.0.244"
End SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long) '取得数据时发生
Dim Tmp As String
Winsock1.GetData Tmp, vbString '取得数据
Tmp = "对方位址:" + Winsock1.RemoteHostIP + "发言内容为-->" + Tmp
txtMess.Text = Tmp + Chr$(13) + Chr$(10) + txtMess.Text
End Sub
只要一按cmdSend就会出现:
Run-time error '10054': The Connection is reset by remote side
解决方案 »
- VB如何远程备份sql2005数据库到本地机中???
- 如何判断当前屏幕区域中有无指定的颜色。
- 用友软件的表格是用什么做的。
- 游标某列合计值用什么语句求?
- PDF_In_The_Box.dll 怎么插入Tif图片
- 为什么我在VB6里面执行 Shell("ping ComputerName -t >a:\aa.txt") 不出错?
- 我用ActiveMovie控件播放VCD文件(*.Dat),我想去掉用户的可控制能力...
- 好久没来vb版了,散分
- 用VB如何实现呢 ????
- 如何判断一个字符串中是否含有中文??谢谢帮忙!!!
- 关于VB系统的问题?
- VB中MouseIcon属性不是设置鼠标图标吗,,为什么运行后,鼠标没有变呀,,,还是老样子呀
Winsock1.bind 5678 '改为绑定试试
Winsock1.RemotePort = 1234Winsock1.RemoteHost = "192.168.0.244"
10054
Connection reset by peer.
An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
所以只收到一半就被关掉了,Winsock的端口一旦打开,如果不合理关闭还是要占用端口。
用Delphi就知道为什么不能用了,解释起来比较麻烦,推荐使用INet,Inet比较好用str=inet1.openurl("www.google.com")
print str
说来惭愧,已开始我只会用TCP,后来才知道有UDP,不过我很少用
你改用
winsock1.bind 5678
试试!