problem with push to talk in the background android

Started by
6 comments, last by _WeirdCat_ 4 years ago

I am developing a push to talk application in the background, I am facing this problem on the client when starting a game: "sendto failed: EPERM (Operation not permitted)" (this problem occurs when sending audio packets - socket.send ( packet)). This game probably also performs UDP communications. What should I do in these cases? Is there any way to tell which package is more important so that android does not block my packages?

Advertisement

The only reason I know of where a sendto() would return EPERM, would be if a firewall prevented the packet from being sent, OR if you're trying to send to a broadcast address without having elevated privileges and enabling broadcast.

Have you bound the socket before sending or not?

Which port and target address are you sending to?

Do any of your packets make it out, according to wireshark? According to return codes?

enum Bool { True, False, FileNotFound };

Packages are sent correctly when the application is in the foreground, when the application is in the background the packages stop being sent. The port used is 50005

This seems like a feature of your Android OS, then. You should read the documentation of the networking interface for that OS and see what you can find out about that.

enum Bool { True, False, FileNotFound };

@undefined right, just one more question how do i listen to two people at the same time without losing the order of the received packages?

I don't undestand the question.

If you have one UDP socket bound to one UDP port, that socket will receive all the packets sent to that port on the host. One of the arguments to recvfrom() is a buffer that will receive the address of whoever sent the packet to you. The order of packet reception is the order of delivery through recvfrom() (generally) and then you use the sender's address to figure out who sent what.

If you need more ordering than that, then each sender can put a sequence number as part of the payload in their packets. In general, a UDP packet will contain something like a session value, a sequence number, perhaps some clock information, and perhaps some other sessin/state management information, before it comes to the “inner payload” of the packet, which might be game state updates, or audio codec data, or whatever.

enum Bool { True, False, FileNotFound };

Did you make your app to be a background session?

This topic is closed to new replies.

Advertisement