Click here to Skip to main content
16,017,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 21-Sep-10 3:46am
v2

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?
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900