开发者

Problem with Android Multicast Sockets

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.

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.

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.

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.)

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

Thanks!

Dan

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


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!

Dan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜