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
解决方案 »
- 如何同时利用INET1下载两个文件
- 现在程序中要同时处理两个数据库,该怎么写事物处理
- MSCOMM控件发送16进制数字的问题
- 一个使用select查询问题(表.0,表.2)?
- setfactory打包工具,在win2k下生成,到win98下问题多多?
- VB使用ACESS来做账号登陆
- 太着急了!!!在机器1运行用Vb做的数据库备份程序,要备份机器2的数据库(局域网内),如何在备份时选择机器2的路径.(象SQL备份数据库那样)
- 关于打印设置对话框(PageSetupDlg)的API调用的问题!(注:回答者必给分,谢谢!)
- 如可求出在 RichTextBox 中 输入光标( "I" ) 的在它里面是那一行那一列上?和它是在 控件 坐标上的 X,Y ?
- 怎样用VB调用SQL语句?
- 关于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
试试!