简体   繁体   English

Java库将所有网络流量从一个端口转发到另一个端口?

[英]Java library to forward all network traffic from one port to another?

I am trying to some JUnit tests that simulate a server across the network dying. 我正在尝试一些模拟跨网络服务器的JUnit测试。 I have an internal utility that allows me to forward traffic from a port on localhost to any port on any other box, and I have used it for these test cases. 我有一个内部实用程序,允许我将流量从localhost上的端口转发到任何其他框上的任何端口,我已将它用于这些测试用例。 The problem is that the utility is written in Python and for Unix only so it's hard to automate it inside Eclipse. 问题是该实用程序是用Python编写的,仅用于Unix,因此很难在Eclipse中自动化它。 My question is: 我的问题是:

Is there a Java library that can allow me to do this automatically at the drop of a method call? 是否有一个Java库可以让我在方法调用时自动执行此操作?

In effect, I want something like Hoxy (which is for Node.js) but for Java. 实际上,我想要像Hoxy (用于Node.js)但是用于Java。

Thanks, Dave 谢谢,戴夫

Does it have to be java? 它必须是java吗? netcat exists and works very well for this sort of thing. netcat存在并且对于这种事情非常有效。

http://29a.ch/2009/5/10/forwarding-ports-using-netcat http://29a.ch/2009/5/10/forwarding-ports-using-netcat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM