关于C#下基于snmpsharpnet的snmp开发中IPV6的问题。

qq_27778559 2015-04-29 12:47:54
在网上找到了一些获取主机的磁盘使用情况的代码:
protected void Button1_Click(object sender, EventArgs e)
{
double[] diskstorage1, diskstorage2;

diskstorage1 = snmpget("127.0.0.1", "public", 1);
this.Label1.Text += Environment.NewLine;
diskstorage2 = snmpget("fe80::357b:bacf:e6b4:5910%3", "public", 2);
//foreach (double dou in diskstorage1)
//{
// this.txtContent.Text += string.Format("{0} GB \r\n", dou.ToString("f2"));
//}
}
如上面的diskstorage2 中,将IP地址写成IPV6的地址就会发生如下错误:

Request has reached maximum retries.

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: SnmpSharpNet.SnmpException: Request has reached maximum retries.

源错误:


行 73:
行 74: // Make SNMP request
行 75: result = (SnmpV1Packet)target.Request(pdu, param);
行 76:
行 77: // If result is null then agent didn't reply or we couldn't parse the reply.

源文件: e:\Program Files (x86)\Visual Studio 2010\WebSites\biyesheji\mange\getDISK.aspx.cs 行: 75

堆栈跟踪:


[SnmpException: Request has reached maximum retries.]
SnmpSharpNet.UdpTransport.Request(IPAddress peer, Int32 port, Byte[] buffer, Int32 bufferLength, Int32 timeout, Int32 retries) +1088
SnmpSharpNet.UdpTarget.Request(Pdu pdu, IAgentParameters agentParameters) +670
mange_Default.snmpget(String ipaddress, String comname, Int32 i) in e:\Program Files (x86)\Visual Studio 2010\WebSites\biyesheji\mange\getDISK.aspx.cs:75
mange_Default.Button1_Click(Object sender, EventArgs e) in e:\Program Files (x86)\Visual Studio 2010\WebSites\biyesheji\mange\getDISK.aspx.cs:22
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628722
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

是否是ipadress这个元数据中没有定义IPV6的相关类,还是UdpTransport中INT32需要改成INT128?如果是该怎么修改?
...全文
280 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_27778559 2015-04-29
  • 打赏
  • 举报
回复
自己先顶顶,没人做过类似的东西么?
qq_27778559 2015-04-29
  • 打赏
  • 举报
回复
不要沉啊!@starft @Z65443344 @wyd1520
qq_27778559 2015-04-29
  • 打赏
  • 举报
回复
继续顶顶吧。
qq_27778559 2015-04-29
  • 打赏
  • 举报
回复
引用 2 楼 xuzuning 的回复:
snmpget("fe80::357b:bacf:e6b4:5910%3", "public", 2); 那个 %3 是什么?
表示这个是Link-local地址
xuzuning 2015-04-29
  • 打赏
  • 举报
回复
snmpget("fe80::357b:bacf:e6b4:5910%3", "public", 2); 那个 %3 是什么?

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧