TCP连接监视器 [英] TCP Connection Monitor

查看:138
本文介绍了TCP连接监视器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何监视两个进程之间的TCP连接.

我的意思是
如果我有服务器应用程序和客户端应用程序,并且它们之间建立了TCP连接,则我希望有第三个进程可以监视此连接并在断开连接时向我发送信号.

实际上,第三个进程需要监视许多进程之间的几个TCP连接,但是从一开始,我认为即使它能够监视单个TCP/IP连接也可以.

解决方案

我将四肢走动,并假设我们正在谈论窗户.

首先,处理套接字的代码应该能够自行将SOCKET_ERROR传递回您的应用程序,或者将您正在寻找的任何错误传递给监视proc/线程,甚至将失败消息发送给您的监视proc/线程.如果遇到阻塞调用挂起的情况,则应该使用异步套接字/调用.

其次,您始终可以使用winsock选择功能来查询套接字 ^ 在查找超时或阻止呼叫失败时很有用,可以根据需要从中取消连接.

您应该问自己的问题是:

为什么要考虑使用监控程序包之后,您真正的目的是什么?

您是否正确设计了网络功能/类?

您是否能够处理错误而无需从外部查看?


是的,我们在这里谈论的是Windows socket.

我没有处理我的应用程序中的错误情况.

当我的recv失败时,我们总能得到我的连接是否断开,但这在同一个应用程序中.

我正在寻找的是另一个进程可以监视两个不同进程之间的套接字连接.

P1通过某个IP端口连接到P2.(Winsock-连接并接受)
P3正在监视该连接状态.(不知道,这是否可能)

如果recv失败并且连接断开,P3可以通知.
我知道P1和P2可以自行通知,但可以由第三进程监视.


是的,请参见此处: http://www.wireshark.org/ [ ^ ]

Wireshark的功能非常强大,它使您可以准确地看到两个或多个进程之间的通信发生了什么.诀窍是学习如何设置适当的过滤器,以免最终无法显示计算机的所有连接.


Hi,

How do i monitor a TCP connection between two processes.

I mean,
If i have a server app & a client app , & a TCP connection is established between them , i want to have a third process which could monitor this connection & would signal me incase it is disconnected.

Actually the third process needs to monitor several TCP connections between many processes, but for the beginning i think even if it is able to monitor a single TCP/IP connection then its fine.

解决方案

I am going to go out on a limb and make the assumption that we are talking about windows.

first things first, your code that handles the sockets should be able to pass SOCKET_ERROR back to your app by itself or what ever error you are looking for or even sending a fail message to your monitoring proc/thread. If you are running into the case where blocking calls are hanging then you should be using asynchornous sockets/calls.

Secondly you can always use the winsock select function to query your sockets ^ usefull when looking for timeouts or failures on blocking calls from which you can cancel the connection if you need to.

The questions you should be asking youself are:

What are you really after why are you considering a monitoring package?

Did you design you networking functions/classes correctly?

Are you able to handle errors without needing to look in from the outside?


Yes we are talking about windows socket here.

N i have handled the error cases within my apps.

We can always get whether my connection is broken when my recv fails , but that is whithin the same app.

What i am looking for is can a another Process monitor a socket connection between two different processes.

P1 connected to P2 on some ip port.(Winsock - connect & accept)
P3 is monitoring that connection state.(Dont know ,whether this is possible)

If recv fails & connection is broken, P3 can notify.
I know that P1 & P2 can themself notify , but can a third process monitor this.


Yes, see here: http://www.wireshark.org/[^]

Wireshark is incredibly powerful, and it will allow you to see exactly what happens in the communication between two or more processes. The trick is to learn how to setup proper filters, so you won''t end up showing all of your computer''s connections.


这篇关于TCP连接监视器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发语言最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆