tags:

views:

32

answers:

2
+1  Q: 

QUdpSocket problem

I try to send data using UDP protocol. Is it possible to understand when UDP dont send data?

Thanks a lot.

I try to a servis which run into client. And they send their IP an port number in one second. Server listen them and if they dont send this message it understand that client is not connected. I do this but I cant understand when they dont send? Do you have any suggestion

A: 

You can check the result of writeDatagram

Sends the datagram at data of size size to the host address address at port port. Returns the number of bytes sent on success; otherwise returns -1.

Then just check the return number to make sure the number of bytes sent was what you expected

SwDevMan81
Thank a lot your answer, I try to a servis which run into client. And they send their IP an port number in one second. Server listen them and if they dont send this message it understand that client is not connected. I do this but I cant understand when they dont send? Do you have any suggestion
ayla
A: 

Of course it's possible, but it might be hard.

I would recommend:

  1. Verify that you don't get errors from your calls to send data (perhaps you're specifying a bad address, or the socket is in a bad state or something).
  2. Try sending more seldom, perhaps your packets are getting dropped by your local network stack.
  3. Make sure you really listen properly at the receiving end, perhaps the packets make it but you fail to read them properly.
  4. Consider firewall/NAT issues, as usual with UDP. Protocol-wise, never include connection information as application data in packets, since then it's invisible to NAT-machines.

The next step might be digging down and trying to get some feedback from the local network stack, or maybe sniffing the network to see if the packets make it some way at least.

unwind
Thank a lot your answer, I try to a servis which run into client.And they send their IP an port number in one second. Server listen them and if they dont send this message it understand that client is not connected. I do this but I cant understand when they dont send? Do you have any suggestion?
ayla
@ayla. Thanks. Feel free to vote up/accept the answer if you find it helpful. I can't totally follow your description, but perhaps you run into firewall/NAT issues, I added an item in my list for these, too.
unwind