Network commands from c++
Results 1 to 10 of 10

Thread: Network commands from c++

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    206

    Network commands from c++

    Does anyone know of a website that could help me learn how to do things like ping/tracert to an inputted ip adress in c++? Thanks,
    Jared
    It is better to die on your feet than to live on your knees.

  2. #2
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,914

    Re: Network commands from c++

    Originally posted here by Jareds411
    Does anyone know of a website that could help me learn how to do things like ping/tracert to an inputted ip adress in c++? Thanks,
    Jared
    Hey Hey,

    As you were having problems compiling a c++ application, it would lead me to wonder just how much c++ knowledge you have. I would suggest first learning the basics of the language before you get into more indepth network programming. www.cplusplus.com is always a decent resource. http://www.tutorialized.com/tutorial...p/Networking/1 has some really decent network programming tutorials.

    Search google, there's a plenthora of information out there. A tutorial that was great for one person may not be a style that you can learn from.

    Peace,
    HT
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Posts
    620
    First if you don't already know basic socket progamming look at this one:

    http://www.ecst.csuchico.edu/~beej/guide/net/html/

    Creating ping and tracert programs would be very difficult. I suggest you just stick with the ping and tracert commands built in to Linux and Windows.

    If you really want to see some source code on it, go to www.pscode.com and search for it on there.

    mjk

  4. #4
    Senior Member
    Join Date
    Feb 2004
    Posts
    620
    Why do I always get beaten?

  5. #5
    Senior Member
    Join Date
    May 2004
    Posts
    206
    Originally posted here by mjk
    Creating ping and tracert programs would be very difficult. I suggest you just stick with the ping and tracert commands built in to Linux and Windows.
    mjk
    I don't want to make a new ping or tracert, I just want to be able to, say, make a program that would ask for an ip adress and then ping it.
    It is better to die on your feet than to live on your knees.

  6. #6
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,914
    Hey Hey,

    If that's all your looking for do a search for Python Intro or Intro Python here on AO. I've written several tutorials on Python and one of them includes calling ping through python... I think that's what you mean. It's written in python, not c++, but python is so much better IMHO, other than the fact that it's interpretted... but the code is almost always cross-platform compliant... a lot more often thatn c/c++ anyways. However in c++ it wouldn't be much harder.... there's a system() function that you can call.

    Code:
    variable = user input
    system("command %variable", variable)
    or something similar to that.....

    Peace,
    HT
    IT Blog: .:Computer Defense:.
    PnCHd (Pronounced Pinched): Acronym - Point 'n Click Hacked. As in: "That website was pinched" or "The skiddie pinched my computer because I forgot to patch".

  7. #7
    Senior Member
    Join Date
    Mar 2003
    Posts
    245
    Hi Jareds411,

    If you aren't yet at the Intermediate C++ programmer stage, I would advise putting a network programming project in C++ off until you have become a more accomplished C++ hacker. If your goal is simply to write some network programs, and or learn about network programming, I would suggest doing it in Perl. Even if you don't know Perl right at this moment, the time it will take you to learn what you need to know and get some socket programming under you belt will be much shorter than the same endeavour in either C or C++. Besides, your Perl code is likely to have less bugs and run faster than a similar program written by a novice C or C++ programmer.

    If Perl sounds like a good jumping off point for this project, I'd recommend heading over to http://www.perl.org/ and scoping out the vast resources on the subject for a place to start. Be sure and check out http://www.cpan.org as well, lot's of good Perl modules related to network tasks.

    Hope that helps.

    -- spurious

    I don't know much about Python except that so many people say it's wonderful to learn to program with.... Definitely take HTRegz's suggestion and give Python a look.
    Get OpenSolaris http://www.opensolaris.org/

  8. #8
    Senior Member
    Join Date
    Feb 2004
    Posts
    620
    Yep, Python rules. Here's what I was able to come up with.

    Code:
    import os
    ip = raw_input("Enter IP address to be pinged: ")
    os.system("ping %s" % ip)
    I would have written an example in C++ for you but unfortunately I'm not familiar with string manipulation.

    mjk

  9. #9
    Ninja Code Monkey
    Join Date
    Nov 2001
    Location
    Washington State
    Posts
    1,027
    I agree with spurious that Perl would also be a better route to take. If you insist on continuing with c++ I'd recommend picking up stroustrups book, a book on the stl, and a good guide for programming on whatever os it is you prefer at the very least.
    "When I get a little money I buy books; and if any is left I buy food and clothes." - Erasmus
    "There is no programming language, no matter how structured, that will prevent programmers from writing bad programs." - L. Flon
    "Mischief my ass, you are an unethical moron." - chsh
    Blog of X

  10. #10
    Banned
    Join Date
    Mar 2003
    Posts
    21
    well u didn't mention about the OS u r using anyway i think u should try this book
    http://www.amazon.com/exec/obidos/tg...74552?v=glance
    and there is also a book for network programming in c++ C++ Network Programming, Volume 2: Systematic Reuse with ACE and Frameworks
    by Douglas C. Schmidt and as always google is ur best friend to if u r looking for a specific command for ping then there no library function in c++ to do that
    affcourse u can make ur own for that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •