在软件中测试网络中断 [英] Testing network interrupts in software

查看:143
本文介绍了在软件中测试网络中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows中有一个网络C ++程序,我想在不同时间测试网络断开情况.我有什么选择?

I have a network C++ program in Windows that I'd like to test for network disconnects at various times. What are my options?

我现在是:

  1. 实际上是从计算机背面断开了网络电缆的连接
  2. 使用ipconfig/release
  3. 使用 cports 程序完全关闭套接字
  1. Actually disconnecting the network wire from the back of my computer
  2. using ipconfig /release
  3. Using the cports program to close out the socket completely

尽管这些方法都不适合我,但我想更轻松地模拟网络问题.

None of these methods though are ideal for me, and I'd like to emulate network problems more easily.

我希望有时连接失败,有时套接字读取失败,有时套接字写入失败.如果有一些我可以用来模拟这些类型问题的实用工具,那就太好了.

I would like for sometimes connects to fail, sometimes socket reads to fail, and sometimes socket writes to fail. It would be great if there was some utility I could use to emulate these types of problems.

在这种模拟的不良网络启动的情况下,能够构建一些自动化的单元测试也是很好的选择.

It would also be nice to be able to build some automated unit tests while this emulated bad network is up.

推荐答案

您可能希望抽象化网络层,然后可以进行单元测试,以便在适当的位置注入有趣的故障事件.

You might want to abstract the network layer, and then you can have unit tests that inject interesting failure events at appropriate points.

这篇关于在软件中测试网络中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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