单触点原始插座 [英] Raw sockets in monotouch

查看:102
本文介绍了单触点原始插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MonoTouch中实现ping功能. 由于某些原因,System.Net.NetworkInformation中的Ping类在实际设备上不起作用,因此我决定切换到原始套接字并自己执行ping操作. 不幸的是,我在以下消息中收到访问被拒绝"消息:

I'm trying to implement ping function in MonoTouch. for some reasons, Ping class from System.Net.NetworkInformation doesn't work on the real device, so I decided to switch to raw sockets and implement ping myself. Unfortunately, I'm getting "Access Denied" message on:

socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);

您知道如何在单点触控中执行ping吗?为什么我不能创建原始套接字?

Any idea how could ping be done in monotouch? And why can't I create raw sockets?

推荐答案

我没有尝试过原始套接字,但是您的访问被拒绝可能意味着它们在iOS中受到限制-就像它们

I have not tried raw socket but your Access Denied likely means they are restricted in iOS - just like they require root privilege on UNIX system. This is the same reason why, in some cases, it was not possible to directly (workaround exists) allow the Ping class to work on Mono for Linux systems.

缺少Ping已知问题,可以通常通过使用可达到性助手. 示例代码可在GIT上获得.

The lack of Ping is a known issue and can generally be worked around by using the Reachability helper. Sample code is available on GIT.

这篇关于单触点原始插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆