Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Networking TCP/IP
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 20-Sep-10 23:42pm
Edited 21-Sep-10 3:46am
Aescleal29.1K
v2
Rate this: bad
good
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?
  Permalink  
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 420
1 OriginalGriff 254
2 Nelek 115
3 Gihan Liyanage 99
4 Sergey Alexandrovich Kryukov 99
0 Kornfeld Eliyahu Peter 420
1 OriginalGriff 140
2 Gihan Liyanage 99
3 Nelek 65
4 sankarsan parida 65


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 10 Oct 2010
Copyright © CodeProject, 1999-2014
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