android UDP connection, not receiving any data(android UDP连接,不接收任何数据)
问题描述
我是这方面的新手,所以如果我问愚蠢的问题,请联系我.
Im a newbie in this so please escuse me if i ask dumb questions.
我正在尝试在 Eclipse 的 PC Emulator 和一部安卓手机
(或两个安卓手机设备之间).
Im trying to make a UDP connection between Eclipse's PC Emulator & a android phone
(or between two android phone devices).
我有一个路由器,手机通过路由器的 wifi 网络连接到互联网.PC 也在同一网络上(直接电缆路由器-PC 连接).我试图将一些文本数据从服务器线程发送到客户端线程,但没有接收/发送任何内容.:(
I have a router and the phone connects to the internet thru router's wifi network. The PC is on same network also (direct cable router-PC connection). Im trying to send some text data from Server thread to Client thread but nothing is received/sent. :(
Server java 类(重新编辑,服务器从客户端接收消息):
和 Client java 类(重新编辑,客户端没有收到来自服务器的消息):
and the Client java class (RE-EDITED, Client does not receive msg from Server) :
在清单中启用了权限:
我在安卓 PC 模拟器上运行服务器,在我的安卓手机上运行客户端.
I'm running the Server on the android PC Emulator, and the Client on my android Phone.
客户和服务器线程运行得很好但是......问题是我没有在它们之间交换任何数据.客户端没有收到任何东西,服务器也没有收到任何东西.数据包已发送,但没有收到任何内容.
Both Client & Server threads run just fine but ... the problem is that i dont get any data exchanged between them. The client doesn't receive anyting and the server doesnt receive anything. The packets are sent but nothing received .
我做错了什么?
请帮帮我.
提前谢谢你.
Please help me.
Thank you in advance.
推荐答案
运行模拟器后,在命令提示符下输入 - telnet localhost",然后输入redir add udp:5000:6000".连接5000端口的客户端,打开6000端口的udp服务器,就可以收到来自udp服务器的客户端消息了.
After running your emulator, type it in command prompt - "telnet localhost ", then type "redir add udp:5000:6000". Connect client with port number 5000 and open udp server with port number 6000. Then you can receive client message from udp server.
查看详情
这篇关于android UDP连接,不接收任何数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!