异步调用的问题

[复制链接]
查看11 | 回复3 | 2021-1-27 06:00:38 | 显示全部楼层 |阅读模式
//ICMP_Testing.cpp:Definestheentrypointfortheconsoleapplication.
//
#include"stdafx.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include"afxdb.h"
#pragmacomment(lib,"wsock32.lib")
#pragmacomment(lib,"ws2_32.lib")
#pragmacomment(lib,"iphlpapi.lib")
usingnamespacestd;

intReplyCame(PVOIDparam)
{
char*szAddr=(char*)param;
printf("ReplayCamefor%s..",szAddr);
return0;
}

int_tmain(intargc,_TCHAR*argv[])
{
LPVOIDReplyBuffer;
fstreamin;
char*ipList[10]={0};;
in.open("input.txt",ios::in);
if(in.fail())
{
std::cout
回复

使用道具 举报

千问 | 2021-1-27 06:00:38 | 显示全部楼层
致命错误:
1char*SendData="DataBuffer";
sizeof(SendData)等于4,即一个指针的大小,而不是你期望的strlen(SendData)。
你可以这样声明charSendData[]="DataBuffer";
2for(intj=0;j<=k;j++)
你的k此时等于10,ipList[10];显然错误啊。应该是
for(intj=0;j<k;j++)
不足之处:
1gethostbyname最好不要输入ip地址,因此通常的做法是:在调用该函数之前,首先判断输入是否是ip地址(调用inet_addr函数)。

这个程序写得有点不好。

回复

使用道具 举报

千问 | 2021-1-27 06:00:38 | 显示全部楼层
楼上的看懂了再说好么。。-
回复

使用道具 举报

千问 | 2021-1-27 06:00:38 | 显示全部楼层
仔细看MSDN,你参数有没有填错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行