SOS:snmp编程-SnmpRecvMsg返回错误 SNMP_NOOP。谁知道怎么办啊? 找了半天,好像没有知道解决办法的 要做基于snmp发现网络拓扑的东西,卡这儿了 大哥大侠们谁能救救我啊? 谢谢啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 API做Get操作,但是总是没有消息返回,SnmpRecvMsg函数错误代码为SNMP_NOOP。就是说没有消息返回 ....这还不清楚阿,发Get请求失败了呗.snmp难在语法的解析上,请求就那么几个... to shawnwan() 可是先发送查询了,应该接受到回复啊这是发送和接收的代码:bool CMySnmp::Send(CStringArray *pstrArr){ HSNMP_VBL hVbl; HSNMP_PDU hPdu; HSNMP_ENTITY hSrcEntity,hDestEntity; smiOID oid; //创建变量绑定列表 hVbl = SnmpCreateVbl(hSession,NULL,NULL); if(hVbl == SNMPAPI_FAILURE){ AfxMessageBox("in send,create vbl failed"); return FALSE; } //循环把请求列表中的项都绑定好 int size = pstrArr->GetSize(); for(int i=0;i<size;i++){ SnmpStrToOid(pstrArr->GetAt(i),&oid); SnmpSetVb(hVbl,0,&oid,NULL); } //按照特定pdu格式发送,返回一个pdu句柄 hPdu = SnmpCreatePdu(hSession,SNMP_PDU_GETNEXT,0,NULL,NULL,hVbl); if(hPdu == SNMPAPI_FAILURE){ AfxMessageBox("SnmpCreatePdu failed"); return FALSE; } hSrcEntity=SnmpStrToEntity(hSession,"127.0.0.1"); hDestEntity=SnmpStrToEntity(hSession,"127.0.0.1"); if(hSrcEntity==SNMPAPI_FAILURE || hDestEntity==SNMPAPI_FAILURE){ AfxMessageBox("SnmpStrToEntity failed"); return FALSE; } //发送 if(SnmpSendMsg(hSession,hSrcEntity,hDestEntity,hContext,hPdu)==SNMPAPI_FAILURE){ AfxMessageBox("SnmpSendMsg failed"); return FALSE; } //释放句柄 SnmpFreeEntity(hSrcEntity); SnmpFreeEntity(hDestEntity); SnmpFreePdu(hPdu); SnmpFreeVbl(hVbl); return TRUE;}bool CMySnmp::Receive(HSNMP_VBL &hVbl){ HSNMP_ENTITY hSrcEntity,hDestEntity; HSNMP_CONTEXT hContext; HSNMP_PDU hPdu; if(SnmpRecvMsg(hSession,&hSrcEntity,&hDestEntity,&hContext,&hPdu)==SNMPAPI_FAILURE){ CString strError; switch (SnmpGetLastError(hSession)) { case SNMPAPI_NOOP: strError="Session当前没有消息在队列中!"; break; break; } AfxMessageBox("消息接收失败!"+strError); return FALSE; } smiINT PDU_type; smiINT error_status; smiINT error_index; if(SnmpGetPduData(hPdu,&PDU_type,NULL,&error_status,&error_index,&hVbl)==SNMPAPI_FAILURE){ AfxMessageBox("SnmpGetPduData failed"); return FALSE; } return TRUE;} Win32屏幕坐标函数是哪个? 求助:MFC开发ActiveX控件时,如何再引入ActiveX控件? 熟悉SQL Server和VC的请进 WaitForMultipleObjects中参数的问题 当自己的对话框被激活,该事件是哪个? 什么样的算法能处理一幅像雾笼罩的图象? 什么是内存泄露呀?只有是动态申请的内存没有释放掉就是内存泄露吗?谢谢 如何给属性页加上图标?请各位高手指点一二 如何将一个菜单项改为有弹出菜单 关于键盘响应的问题 开发键盘过滤驱动实现模拟按键过程中遇到的问题分析,顺便请大家给点模拟按键的资料 送分问题:CView 有没有关闭事件?
可是先发送查询了,应该接受到回复啊这是发送和接收的代码:bool CMySnmp::Send(CStringArray *pstrArr){
HSNMP_VBL hVbl;
HSNMP_PDU hPdu;
HSNMP_ENTITY hSrcEntity,hDestEntity;
smiOID oid; //创建变量绑定列表
hVbl = SnmpCreateVbl(hSession,NULL,NULL);
if(hVbl == SNMPAPI_FAILURE){
AfxMessageBox("in send,create vbl failed");
return FALSE;
} //循环把请求列表中的项都绑定好
int size = pstrArr->GetSize();
for(int i=0;i<size;i++){
SnmpStrToOid(pstrArr->GetAt(i),&oid); SnmpSetVb(hVbl,0,&oid,NULL);
} //按照特定pdu格式发送,返回一个pdu句柄
hPdu = SnmpCreatePdu(hSession,SNMP_PDU_GETNEXT,0,NULL,NULL,hVbl);
if(hPdu == SNMPAPI_FAILURE){
AfxMessageBox("SnmpCreatePdu failed");
return FALSE;
}
hSrcEntity=SnmpStrToEntity(hSession,"127.0.0.1");
hDestEntity=SnmpStrToEntity(hSession,"127.0.0.1");
if(hSrcEntity==SNMPAPI_FAILURE || hDestEntity==SNMPAPI_FAILURE){
AfxMessageBox("SnmpStrToEntity failed");
return FALSE;
}
//发送
if(SnmpSendMsg(hSession,hSrcEntity,hDestEntity,hContext,hPdu)==SNMPAPI_FAILURE){
AfxMessageBox("SnmpSendMsg failed");
return FALSE;
}
//释放句柄
SnmpFreeEntity(hSrcEntity);
SnmpFreeEntity(hDestEntity);
SnmpFreePdu(hPdu);
SnmpFreeVbl(hVbl); return TRUE;
}
bool CMySnmp::Receive(HSNMP_VBL &hVbl){
HSNMP_ENTITY hSrcEntity,hDestEntity;
HSNMP_CONTEXT hContext;
HSNMP_PDU hPdu; if(SnmpRecvMsg(hSession,&hSrcEntity,&hDestEntity,&hContext,&hPdu)==SNMPAPI_FAILURE){
CString strError;
switch (SnmpGetLastError(hSession))
{
case SNMPAPI_NOOP:
strError="Session当前没有消息在队列中!";
break;
break; }
AfxMessageBox("消息接收失败!"+strError);
return FALSE;
} smiINT PDU_type;
smiINT error_status;
smiINT error_index; if(SnmpGetPduData(hPdu,&PDU_type,NULL,&error_status,&error_index,&hVbl)==SNMPAPI_FAILURE){
AfxMessageBox("SnmpGetPduData failed");
return FALSE;
}
return TRUE;
}