-
June 28th, 2004, 01:48 AM
#1
Junior Member
Any Good TCP/IP Book Out There?
does anyone know of a good programing book for tcp/ip, lang c++. i have a basic understanding for the osi model along with c++ in gerneral. is there a good step by step, a book that will hold my hand, through the process of writing programs that use tcp/ip? i'm looking to writing my own program that will ping address, or string of address. i've made my own program that will create a batch file, that when run, will ping a string of ip address, that creates a *.txt file on the results. very tedious looking throught the txt file to see which hosts are alive. i will post my source code for further understanding.
do it now and ask for forgiveness later
-
June 28th, 2004, 01:52 AM
#2
Junior Member
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::cerr;
using std::ios;
using std::endl;
#include <fstream>
using std::ofstream;
#include <cstdlib> //edit prototype
int main()
{
int ipa; //first segment of ip address
int ipb; //second segment of ip address
int ipc; //third segment of ip address
int ipd; //fourth segment of ip address
int ipmax; //the number to stop on
int range; //qusetion if the range is correct
int end; //asks if user wants to start over or end
//ofstream constructor opens file
ofstream outClientFile( "ping.bat", ios::out );
begin:
cout << "This program was made by Drhavagner.\n";
cout << "Email me at\n\n";
cout << "drhavanger@yahoo.com\n\n";
cout << "for all your programing needs.\n";
cout << "\n\nThis program will create a Ping.bat file\n";
cout << "that will ping a range of ip address.\n";
cout << "The Ping.bat file will then create a Ping.txt\n";
cout << "file that will show the results of the ping.\n";
cout << "You will enter the ip address one segment at a time.\n";
cout << "Don't include the periods.\n\n\n";
ipab:
cout << "Enter first segment number:";
cin >> ipa;
if (ipa > 255)
goto ipa255;
ipbb:
cout << "Enter second segment number:";
cin >> ipb;
if (ipb > 255)
goto ipb255;
ipcb:
cout << "Enter third segment number:";
cin >> ipc;
if (ipc > 255 )
goto ipc255;
ipdb:
cout << "Enter fourth segment number:";
cin >> ipd;
if (ipd > 255 )
goto ipd255;
iprange:
cout << "Enter the number to end on:";
cin >> ipmax;
if (ipmax <= ipd)
goto ipless;
if (ipmax > 255)
goto ipmax255;
cont:
cout << "\n\nThe ip address that you want to start with is: "<<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipd<<"\n";
cout << "The ip address that you want to end on is: "<<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipmax<<"\n\n";
cout << "If this is correct press -2-, if this is incorrect, press -8-.\n\n";
cin >> range;
cout <<endl;
if (range == 2)
goto print;
if (range == 8)
goto begin;
if (range != 2 && range != 8)
goto cont;
print:
cout <<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipd<<"\n";
outClientFile <<"Ping.exe -n 1 -l 10 "<<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipd<<">>ping.txt"<<endl;
while ( ipd < 255 && ipd < ipmax)
{
++ipd;
cout <<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipd<<"\n";
outClientFile <<"Ping.exe -n 1 -l 10 "<<ipa<<"."<<ipb<<"."<<ipc<<"."<<ipd<<">>ping.txt"<<endl;
}
question:
cout << "\n\nTo start program over type -1-, or to end, type -9-.\n\n";
cout << "WARNING! STARTING THE PROGRAM OVER WILL OVERWRITE THE PING.BAT FILE!\n";
cin >> end;
if ( end == 1 )
goto begin;
if ( end == 9 )
goto end;
if (end != 1 && end != 9)
goto question;
//***********************ERROR MESSAGES********************************************************
ipa255:
cerr<< "\nYou entered a value greater than 255. Please enter a number less than 255.\n\n";
goto ipab;
ipb255:
cerr<< "\nYou entered a value greater than 255. Please enter a number less than 255.\n\n";
goto ipbb;
ipc255:
cerr<< "\nYou entered a value greater than 255. Please enter a number less than 255.\n\n";
goto ipcb;
ipd255:
cerr<< "\nYou entered a value greater than 255. Please enter a number less than 255.\n\n";
goto ipdb;
ipless:
cerr<< "\n\nYou entered a value that is less than your fourth segment number or equal to.\n";
cerr<< "Please enter a number greater than the fourth segment number.\n";
cerr<< "Your fourth segment number is: "<<ipd<<"\n\n";
goto iprange;
ipmax255:
cerr<< "\nYou entered a value greater than 255. Please enter a number less than 255.\n\n";
goto iprange;
end:
return 0;
}
-
June 28th, 2004, 01:54 AM
#3
Junior Member
in no way do i entend to use my knowledge, or any knowledge gained, for malicous intent.
do it now and ask for forgiveness later
-
June 28th, 2004, 09:20 AM
#4
Paralyse, other members may help you better than I do.
I have one comment tho... While SOMETIMES it is really necessary to use goto to simplify the code and/or to speed up the runtime process, I don't see goto is needed here. It even (I think) complicates your code.
Try using if ... else ... blocks. I see you have used while, that's good. Then you can use system() to execute ping.exe directly. Have fun!
Peace always,
<jdenny>
Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds
-
June 28th, 2004, 05:47 PM
#5
Junior Member
thank you for your comments and insight. i used the goto command becuase i wanted to have all the error messages all together. i guess i'm lazy. maybe i'll tweek it when i get a good tcp/ip book, if anyone knows of one
do it now and ask for forgiveness later
-
July 28th, 2004, 09:17 AM
#6
Senior Member
do u need the book for Network Programmig?
U get What U pay for.
-
July 28th, 2004, 09:21 AM
#7
Senior Member
this is considered to be a good book for Unix network programming, i personnaly have not started reading it, but will start soon.
Author Stevens, W. Richard.
Title : UNIX network programming / W. Richard Stevens, Bill Fenner, Andrew M. Rudoff.
Imprint : Boston, MA : Addison-Wesley, c2004
i hope this helps u mate, if u need more information let me know we can search it out.
U get What U pay for.
-
July 28th, 2004, 10:47 AM
#8
Hands down the best book about TCP/IP is TCP/IP Illustrated by W. Richard Stevens.
I can recommend all three volumes. The last volume is more programmers based and talks about ways to setup services and using the protocols in C.
Oliver's Law:
Experience is something you don't get until just after you need it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|