本地(但不是本地)套接字测试 [英] Local (but not local) Sockets Testing

查看:70
本文介绍了本地(但不是本地)套接字测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在基于此示例在(C ++,winsock,TCP/IP中)实现异步套接字编程 Chat Client Server [ ^ ])(用于数据流传输),并且当我通过网络而不是本地运行代码时,会遇到丢失数据的问题(尽管每隔0.1s发送一次,但我似乎仅每0.7s接收到一个数据包).

我的同事每次想调试时都要求我的同事在他的计算机上运行客户端代码是一件很痛苦的事情,所以我想知道是否可以在同一台计算机上运行我的客户端和服务器,但是可以通过物理网络和网络发送消息. ;路由器,重新创建同样的问题?因此,实际上我没有将客户端连接到127.0.0.1,而是将其连接到我的IP地址,并且消息通过了我的物理集线器.

这可能吗?还是我吠错了树? :confused:

谢谢,

Ad

解决方案

以我的经验,在与服务器位于同一台计算机上的虚拟机中运行客户端可以使您非常逼真地模拟实际的客户端-服务器环境.我们公司使用VMWare和Microsoft的虚拟化产品进行调试和质量检查;两者都很好地达到了我们的目的.看来这种方法也可能适用于您的情况-框架和OS中的代码路径与非本地客户端-服务器方案中的相同,只是数据包不会传递到路由器并返回. blockquote>

虚拟机可能是这里的答案;但我建议您从雇主那里购买另一台专用的测试机,因为在实际物理层上进行测试要比任何类型的模拟都要好得多.

再想一想,您还可以做一件事,
1.为您的计算机获取另一张网卡
2.将其连接到交换机并分配IP地址
3.您将在计算机上获得两个不同的IP地址
4.在一个IP上运行服务器,并在另一个IP上运行客户端.


一些您可能不知道的指针:

可以通过从远程计算机或VM上的C:\ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ Remote Debugger \<平台> \ msvsmon.exe运行msvsmon.exe来设置远程调试.它位于64位计算机上的64位程序文件中,然后在项目属性的调试页中,从下拉列表中选择远程Windows调试器".
数据包通常是串联在一起的,因此,如果您的代码花很长时间才能重新进行检查,则可能每0.7秒就会收到7个数据包.


Hi Everyone,

I''m implementing asynchonous socket programming in (C++, winsock, TCP/IP, based on this example Chat Client Server[^]) at the moment (for data streaming) and am running into problems with missing data when I run the code over a network rather than locally (I only seem to recieve a packet every 0.7s, despite sending them every 0.1s).

Its a pain to ask my colleague to run my client code on his computer everytime I want to debug, so I wonder if it''s possible to run my client and server on the same machine but to send the message over a physical network & router, to re-create the same problem? So, instead of my client connecting to 127.0.0.1, I actually connect it to my IP address and the message goes through my phsycial hub.

Is this possible? Or am I barking up the wrong tree? :confused:

Thanks,

Ad

解决方案

In my experience, running your client in a virtual machine on the same computer as the server lets you simulate real-world client-server environments very realistically. Our company used VMWare''s and Microsoft''s virtualization products for debugging and in QA; both worked very well for our purposes. It looks like this approach may work in your case as well - the code path inside the framework and OS will be the same as in a non-local client-server scenario, except the packets will not travel to the router and back.


Virtual machine might be an answer here; but I advice that get another dedicated machine for testing from your employers since it will be far better to test on actual physical layer than any kind of simulation.

On a second thought, there is one more thing you can do,
1. Get another network card for your machine
2. Connect it to a switch and assign IP address
3. You will get two different IP addresses on your machine
4. Run server on one IP and client on another and connect them.


A few pointers that you may or may not already know:

Remote debugging can be set up by running msvsmon.exe from C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\<platform>\msvsmon.exe on the remote computer or VM. This is in the 64-bit Program Files on a 64-bit computer, then in the debugging page of the project properties select Remote Windows Debugger from the drop-down list

Packets are generally concatenated together, hence you might be receiving 7 packets every 0.7 seconds if it takes your code that long to get back around to checking.


这篇关于本地(但不是本地)套接字测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆