Thread: Read communication data of process by port number

  1. #1
    Registered User
    Join Date
    Mar 2010

    Question Read communication data of process by port number

    Hello All,

    I made 2 programs winserver.exe and winclient.exe file. Both program are sending and receiving message by socket. I am wanting to make 3rd program which will fetch data of receiving and sending by PORT number of pc. This 3rd program will be kept on both pc and when both client and server will be communicate then this 3rd program will track messages of communication.

    Is this possible to find data in socket by PORT number (hooking program)?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    You may want to investigate libpcap. The only way you can do this without directly intercepting the data (eg, having the data send by the server to the third program to pass on to the client, and the same thing in reverse) is to go below the tcp/ip socket layer. The only way I know to do that is with pcap.

    If you want an understanding of what this is about, check out a packet sniffer such as "Wireshark", which uses libpcap.
    Last edited by MK27; 03-22-2010 at 08:00 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Mar 2010

    Red face

    #include <pcap.h> /* if this gives you an error try pcap/pcap.h */

    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    #include <netinet/if_ether.h> /* includes net/ethernet.h */

    I am not getting these header file in my include directory . Can anybody from where i can download these headers. I am using Vc++6 and Dev c++. in both inerface i am getting error.

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    I'm guessing you shouldn't be including Unix headers on a Windows system. You need winpcap (and I don't think it comes "out of the box") and winsock. I don't know whether you'll need an equivalent for the ethernet header, and if you do, I don't know what it is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. read data from USB Port
    By hello_world in forum C Programming
    Replies: 1
    Last Post: 12-30-2009, 08:52 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. how can i read data from com port
    By Albert franklin in forum Networking/Device Communication
    Replies: 3
    Last Post: 08-17-2004, 11:12 AM
  4. how to make parallel port read data
    By lwong in forum Windows Programming
    Replies: 0
    Last Post: 01-05-2004, 08:14 PM
  5. read data
    By in_need in forum C Programming
    Replies: 2
    Last Post: 10-30-2001, 08:10 AM