0

我想以某种方式使用 java/scala 控制我计算机上的活动套接字。例如,如果一个程序已经建立了一个 tcp 连接,我希望能够检索和监听/写入这个套接字。

所以,第一个问题是:这可能吗?第二个:如何?

4

2 回答 2

0

I found a java wrapper of lipcap http://jnetpcap.com/ that let me do the sort of things i was after. From the web: jNetPcap is an open-source java library. It contains:

A Java wrapper for nearly all libpcap library native calls Decodes captured packets in real-time Provides a large library of network protocols (core protocols) Users can easily add their own protocol definitions using java SDK jNetPcap uses a mixture of native and java implementation for optimum packet decoding performance

于 2013-09-01T19:16:55.197 回答
0

您可以通过编写自定义 Socket 工厂来做到这一点。这是相当复杂的,我不建议你这样做,除非你试图破解一个你无法控制的程序(这也是一个非常糟糕的主意)

相反,我建议您监控自己的使用情况。当您从 Socket 读取/写入时,您还会保留所需的任何信息。即它是你的程序,所以改变它来做你需要的。

于 2013-09-01T18:47:33.740 回答