Click here to Skip to main content
13,196,730 members (57,517 online)
Rate this:
Please Sign up or sign in to vote.

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 20-Sep-10 23:42pm
Updated 21-Sep-10 3:46am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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?
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Yes, see here:[^]

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171019.1 | Last Updated 10 Oct 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100