Listen to a port

I need to write an app which would listen to a certain port number, used by another program P (both running on my computer), and log all data passing through this port. My app must not interfere with P, and the only reason I need it for is to see what P is sending/receiving at this port.

I do not even know if it's possible. Any suggestions on how I can do this ?
LVL 1
olegspAsked:
Who is Participating?
 
mattdaimonConnect With a Mentor Commented:
You should use winsock(windows sockets).
You can do it either directly or with the help of some class like CAsyncSocket( better use it than CSocket). You should listen to port(in winsock you can do it by 'bind' function) then write data you reseived to disk and analyze it how you want. I think that there are examples in MSDN or at codeguru.
0
 
pagladasuCommented:
Take a look at this site. Maybe, it will help you:
http://www.codeguru.com/network/commspy.shtml
0
 
anoopsCommented:
I guess, you can use CSocket in the client mode of this purpose. See the documentation in MSDN for CSocket
0
 
kishk91Commented:
btw. the new address of codeguru
is:
http://codeguru.developer.com

the old address is no longer available.

regards
kishk91
0
All Courses

From novice to tech pro — start learning today.