扫描程序源文件的代码实现

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
continue;//run a continue to scan the next port
}
}
break;
default:
printf(help);
break;
}
return 0;
}
char temp[255];
string ip;
int start;
int end;
int i=0;
TCPSocket *tcs;
switch(argc)
{
case 4:
//argv[1] ip to scan, argv[2] is the start port, argv[3] is the end port
ip=argv[1];
starFra Baidu bibliotek=atoi(argv[2]);
end=atoi(argv[3]);
for(i=start;i<=end;i++)
{
try
{
sprintf(temp,"testing %i\n",i);
fputs(temp,stdout);
tcs = new TCPSocket;
//try and connect to the port...if connection fails an exception is thrown
下面是一个扫描程序的源代码
#include <stdio.h>
#include <string>
using namespace std;
#include "PracticalSocket.h"
int main(int argc, char **argv)
{
char help[]="\n usage: address start end\n";
tcs->connect(ip,i);
sprintf(temp,"open port at %i\n",i);
fputs(temp,stdout);
//if we succeeded in connecting to a port
delete tcs;
}
catch(SocketException ex)
相关文档
最新文档