背景:
我正在Nexus 7(Android API级别22)上运行跨平台Xamarin.Forms应用,该应用配置为(按顺序):
10.0.0.0/5000
)上运行的Python脚本启动时。
Visual Studio 2019 Preview (v16.0.0 Preview 1.1)
,Xamarin.Forms (v3.4.0.1008975)
和Xamarin.Android (v28.0.0)
。hostapd
和dnsmasq
的Raspberry Pi 3 B +托管。该访问点分发10.0.0.1
到10.0.0.20
范围内的IP地址,默认网关为10.0.0.0
。该网络当前没有Internet,但将来可能会添加它。TcpClient
连接到此脚本,以便它可以从Pi接收传感器数据。问题:
该应用程序已成功连接到WiFi和蓝牙(步骤1和3),但是在尝试连接到Python脚本(步骤2)时,我收到了System.Net.Sockets.SocketException
(HRESULT:0x80004005
)。 )。这是堆栈跟踪:
{System.Net.Sockets.SocketException (0x80004005): Network is unreachable
at System.Net.Sockets.SocketAsyncResult.CheckIfThrowDelayedException ()
[0x00014] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Net.Sockets.Socket.EndConnect (System.IAsyncResult asyncResult)
[0x0002c] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Net.Sockets.TcpClient.EndConnect (System.IAsyncResult asyncResult)
[0x0000c] in <165f7048c1ba483e8b4fcc215c691e9e>:0
at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic
(System.IAsyncResult iar, System.Func`2[T,TResult] endFunction,
System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult]
promise, System.Boolean requiresSynchronization) [0x00019] in
<76298308b9444eca9d8db328b3554473>:0
--- End of stack trace from previous location where exception was thrown ---
at Liberty_Console.Models.Statics+<ConnectAsync>d__2.MoveNext () [0x00052]
in C:\Users\Micah\Source\Repos\Liberty Console\Liberty Console\Liberty
Console\Models\Statics.cs:27 }
这是导致它的代码:
TcpClient client = new TcpClient(AddressFamily.InterNetwork);
await client.ConnectAsync("10.0.0.0", 5000); //System.Net.Sockets.SocketException
我有
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_WIFI_STATE
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.CHANGE_NETWORK_STATE
android.permission.CHANGE_WIFI_STATE
android.permission.INTERNET
10.0.0.X
)5000
在路由器/网关上打开System.Net.NetworkInformation.Ping
类对路由器/网关执行ping操作
我的推论:
根据我的测试和调试,看来该应用程序无法在网络上发出请求(因此它“无法访问”)。这可能是由于:
192.168.1.X
而非10.0.0.X
上运行)非常感谢您的帮助!
让我知道问题是否需要更多细节或澄清。