Thread: Creating a PING PROGRAM help??

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    2

    Creating a PING PROGRAM help??

    Okay so I have got part of it but like parts are missing that would be interesting or hand to know how to do. So like what I am looking for is a ping program with commands or possibly a windows and you type in the remote address and the size of the packet you will send. I have gotten this far can anyone help me?

    Code:
    #include<windows.h>
    int main()
    {
    system("ping host address");
    return 0;
    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you have several steps to do
    1. create a fucntion that will send a request
    2. for now - you can use you system approach
    3. you will use sprintf to form a command
    [code]
    char buffer[1024];
    sprintf(buffer,"ping &#37;s -l %d > res.txt", hostname, size);
    system(buffer);
    4. and other function that will parse the res.txt file to present the result

    5. After that you can build simple GUI program that will use these 2 functions
    6. After that you can switch to using winsock2 library and create ping packet directly and process the response in a proper way
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058

  5. #5
    Registered User
    Join Date
    Feb 2008
    Posts
    2
    Quote Originally Posted by carlorfeo View Post
    That doesn't however address the issue of being able to change the packet size. Which seem s to be the hardest and most confusing.

  6. #6
    coder
    Join Date
    Feb 2008
    Posts
    127
    Yes, I linked that just to give you an example to start from.
    You will need to set the correct "ping" option to manage the packet length.
    In a Linux terminal <man ping> will display the command's manual. I have no clue about windows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  2. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  4. creating a simple program to accept a password.
    By boy1015 in forum C++ Programming
    Replies: 11
    Last Post: 02-05-2002, 08:34 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM