套接字编程Xp>远景、远景> XP
我正在开发一个程序,将图像从一台计算机发送到另一台计算机(类似于无需鼠标/键盘输入的远程协助)。我用来测试的两台计算机是一台 Windows XP 计算机和一台 Windows Vista 计算机。我的固定 XP 机器直接连接到路由器,还有一台通过无线连接的笔记本电脑。
从 XP 到 Vista 的传输效果很好,我能够获得在 Vista 上显示的持续图像流。但是,当我翻转它并将图像从 Vista 发送到 XP 时,它不起作用。我还尝试了本地“复制”,即无需网络即可获取图像流,这适用于 Vista 和 XP。两台机器上的程序完全相同。
我认为这并不重要,但我正在使用 GDI+ 来处理图像。因此,我通过网络上的流发送 .jpg 并在另一端重建它。
我的网络消息类称为 NetMsg
。它由 char* 类型
和 char* 数据
组成。类型决定了我如何解释数据,这里没有问题。
我们将计算机称为#1 和#2。
创建连接后,我在 #1 上标记了要发送的区域:
001>#1 发送 RESIZE // 类型,使 #2 上的窗口与我在 #1 上标记的区域大小相同
002>#1 发送类型 PICTURE_DATA // 这是实际的图像数据
003>#2收到以上两条消息后,发送类型REQUEST_MORE // #2想要更多图像数据
004>#转到步骤1
当将图像数据从XP发送到Vista时,我什至没有费心去调试它,因为它工作得很好,完全像我想要的那样。然而,当 Vista 发送到 XP 时,我注意到以下情况:
- 收到的数据实际上可以是两个
NetMsgs
。我通过将数据分成几个NetMsgs
来支持这一点。 - 收到的数据可能不完整,也就是说我必须等待更多数据。我通过将 NetMsg 标记为不完整并在下一次数据传输时完成它来支持这一点。 (以及第一步的组合)
这几乎成功了,因为我正确传输了一些图像,但随后它突然停止了。我还没有彻底调试过,所以我不知道为什么数据突然停止了。但是:
我不明白的是,当从 XP 发送到 Vista 时,这效果很好,但反之则不然。我缺少什么?
如果您需要代码摘录,请告诉我,但是,它非常大......大约 500 行......否则我会寻找从 Vista 发送数据到 XP 时的已知问题。
任何帮助和/或反馈表示赞赏!
I am developing a program which sends images from one computer to another (similar to remote assistance without mouse/keyboard input). The two computers I use to test this are one Windows XP machine and one Windows Vista. I have the stationary XP machine directly connected to a router, and a laptop which is connected through wireless.
The transmission from XP to Vista works great, I am able to get a constant flow of images that are displayed on Vista. However, when I flip it and send images from Vista to XP it does not work. I also tried a local "copy", that is, without the network get a flow of images and this works on Vista as well as XP. It is the exact same program on both machines.
I don't think it matters but I am using GDI+ for the images. So I send a .jpg through a stream on the network and rebuild it on the other side.
My Network Message class is called NetMsg
. it consists of a char* type
and a char* data
. the types determine how I interpret the data, no issues here.
Let's call the computers #1 and #2.
When connection is created and I marked the area on #1 that I want to send:
001>#1 sends type RESIZE // to get the window on #2 the same size as the area I have marked on #1
002>#1 sends type PICTURE_DATA // this is the actual imagedata
003>#2 after received the two above messages, sends type REQUEST_MORE // #2 wants more imagedata
004>#go to step 1
I haven't even bothered to debug it when sending image data from XP to Vista, since it works great, exactly like I want it. However when Vista sends to XP I have noticed the following:
- Data received can actually be two
NetMsgs
. I have support for this by splitting the data into severalNetMsgs
- Data received can be incomplete, that is I have to wait for more data. I have support for this by marking a
NetMsg
as incomplete and on the next datatransmission complete it. (as well as a combination of the first step)
This almost did the trick because I got some images transferred correctly, however then it suddenly stopped. I have not debugged this thoroughly so I do not know why the data suddently stopped.. However:
What I do not understand is that this works great when sending from XP to Vista but not the other way around. What am I missing?
Do let me know if you need extracts of code, however, it is pretty huge... roughly 500 rows.. Otherwise I am looking for known issues when sending data from Vista to XP.
Any help and/or feedback appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
很难真正肯定地说出任何事情。但是,我强烈建议您为您的程序编写一个测试套件,并实现一个测试用例来捕获这个特定问题。这将使您更容易重现故障,并且尝试生成可以证明问题的最小测试用例通常非常有启发性。此外,当您拥有(全自动)测试用例时,向其他人寻求帮助也更容易。
It is difficult to really say anything with any certainty. However, I would strongly suggest that you write a test suite for your program and implement a test case which catches this particular problem. This will make it easier for you to reproduce the failure, and it is often very instructive to try to produce a minimal test case which can demonstrate the problem. Also, when you have a (fully automatic) test case, it is also easier to ask someone else for help.
您真正需要做的是更详细地描述问题。 “它不起作用”可能有数百个原因。
你有数据通过吗?
尝试只发送几个字节,它们能通过吗?
如果没有任何结果,请尝试使用Wireshark,Vista 是否将数据发送出去?
XP 收到了吗?
这里没有魔法,您必须从头到尾检查数据路径。
What you really need to do is describe the problem in more detail. There could be 100's of reasons why "it isn't working".
Are you getting any data through?
Try sending just a few bytes, do they get through?
If nothing is getting through, try using Wireshark, is Vista sending the data out?
Is XP receiving it?
No magic here, you will have to check the data path from start to finish.
它实际上在两台计算机上都被阻塞,并且都在等待对方的响应。
It was actually blocking on both computers and both were waiting for the other to respond.