我已经复制/粘贴了这个 tutorial about sockets on Android 中的代码.
它构建良好并按预期运行,直到尝试连接。
我已将它与 USB 连接,并使用 ADB 开启端口转发。
我用 C# 编写了测试应用程序(我对它比 Java 更熟悉)并且我不断收到 error 10061 :
No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.
当我使用 SocketTest 时,我收到以下(相当神秘的)消息:
Connection error: connect
我试过禁用我的防火墙,但这没有帮助。有什么问题吗?
最佳答案
“主动拒绝”意味着目标已发回一个数据包,表示没有进程在端口上监听(“没有服务器应用程序正在运行”)。一些防火墙甚至会过滤这些数据包,导致在尝试连接时超时。
关于java - 使用 Android 套接字时,为什么连接是 "actively refused"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11035970/