vb6中winsock溢出问题
我建立了一个使用“Winsock”工具的简单项目。
当我收到任何数据时,我将其放入变量中,因为我无法将其放入文本框中,因为 它是一个文件而不是文本。
但如果我发送一个大文件,就会出现错误。
“溢出”
有什么办法可以解决这个问题吗?
I have built a simple project which use "Winsock" Tool.
When I receive any data I put it in a variable because i cann't put it in a textbox because
it is a file not a text.
But if i send a big file it gets me an error.
"Overflow"
Are there any way to fix this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
(VB6 中字符串的最大长度)
如果这是您的问题,请尝试拆分传入的数据由多个字符串组成。
(maximum length for string in VB6)
If this is your problem, try splitting incoming data by several strings.
在发送更多数据之前,您是否正确处理了 SendComplete 事件?
否则,WinSock 控件将导致缓冲区溢出。
Are you handling the SendComplete event properly before sending more data?
Otherwise you will get a buffer overflow from the WinSock control.
您需要将数据分成更小的数据包(每个数据包大约 2-5k)并单独发送每个数据包,然后在另一端重新构建数据包。您可以在数据末尾添加一个唯一字符,以便接收端知道已收到该传输的所有数据,例如
Chr(0)
?这是解决这个问题的一个相当简单的解决方案 - 更好的方法是设计一个简单的数据握手协议,这样您就知道每个数据包都已收到。
You need to split your data into smaller packets (around 2-5k each should do it) and send each packet individually, then re-construct your packets at the other end. You could add a unique character at the end of the data so that the receiving end know that all the data has been received for that transmission say
Chr(0)
?This is quite a simplified solution to this problem - a better method would be to devise a simple protocol for data handshaking so you know each packet has been received.