问题与Android组播套接字 [英] Problem with Android Multicast Sockets

查看:139
本文介绍了问题与Android组播套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行在Nexus One上有些code - ,我有一个很奇怪的问题。 服务器,手机已加入组播套接字上发送UDP数据包了。手机接收和发送的东西多播组精细,但现在看来,手机的时候就在同一时间接收大量数据包的扼流圈。

I'm running some code on the nexus one - and I am having a very strange issue. The "server" sends UDP packets out on the multicast socket that the phone is joined to. The phone receives and sends stuff to the multicast group fine, but it appears that the phone chokes when it receives a large number of packets at one time.

例如,服务器偶尔会发出80左右,在一个512字节的包出去转转。手机开始接收数据包,但随后在第31包(〜数据的16KB)接收挂起(表示没有什么插座上了。)我已经做Wireshark的测试之类的东西,所以我肯定知道包不被丢失。即使有些正在丧失,这是非常奇怪的是,每次测试产生相同的结果---大量数据被一次卡到插座,但插座只允许我socket.receive()为16KB价值数据。

For example, the server will occasionally send out 80 or so 512 byte packets in one go around. The phone starts receiving the packets, but then at the 31st packet (~16KB of data) the receive hangs (indicating that there is nothing on the socket anymore.) I've done wireshark testing and stuff so I know for sure that the packets are not being lost. Even if some are being lost, it is very strange that EVERY test produces the same result --- a large amount of data gets jammed onto the socket at one time, but the socket only allows me to socket.receive() for 16KB worth of data.

我曾尝试socket的()具有多种价值(可达1MB) - 但似乎并没有工作。有趣的是,到getReceiveBufferSize()的调用告诉我,插座应持有大约100KB有价值的数据。

I have tried socket.setReceiveBufferSize() with a variety of values (up to 1MB) -- but that doesn't seem to work. Interestingly, a call to getReceiveBufferSize() tells me that the socket should hold roughly 100KB worth of data.

如果我告诉服务器减慢其发送方法(我不能部署,我只能做到这一点用于测试目的) - 一切正常,presumably因为数据包不卡住手机上的插座全部在同一时间(即我告诉服务器等待1/2包之间的第二次。)

If I tell the server to slow down its send method (which I cannot deploy, I can only do that for testing purposes) - everything works fine, presumably because the packets aren't jammed onto the phone's socket all at one time (ie. I tell the server to wait 1/2 a second between packets.)

有没有其他人经历过这样 - 如果有的话 - 你怎么围绕它得到什么?我的无法的应用程序切换到TCP。

Has anyone else experienced this - if so - how did you get around it? I cannot switch the application to TCP.

谢谢!

PS。在Java code工作正常,如果我一个普通的机器上运行它...

PS. The Java code works fine if I run it on a regular machine...

推荐答案

算了 - 不知道与网络我是上升了 - 我被移动到一个封闭的网络中有0可能性损失和怪异的东西固定它(这应该是咕) - 但至少它的工作原理

Nevermind - I fixed it by moving onto a closed network where there is 0 possibility for loss and weird things -- not sure what was up with the network I was on (which was supposed to be goo) - but at least it works!

这篇关于问题与Android组播套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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