   partial sendto()
  Hello, I've looked into docs for Winsock 2 and all over the web and couldn't find the answer I'm looking for.I want to know what happens when i tell sendto() to send 512 bytes but 412 is returned. Does that mean that if I decide to not send the rest, the receiving side(in the case the packet is not lost) will receive a packet of 412 bytes ?If i create a function that makes sure the complete data gets sent, over multiple game frames (to make sure it never blocks) how can I be assured that the OS layer will not send the 412 bytes i told him to before i have time to send the 100 remaining bytes ?This is somewhat tricky, I'm not expecting a lot of replies. But if you have any experience with UDP sockets sendto() / recvfrom() that you would like to share, please feel free to do so.Thanks   
  UDP packets can only be sent as a whole.Documentation isn't really helful here though:Quote:If no error occurs, sendto returns the total number of bytes sent, which can be less than the number indicated by lenBut I don't see how this would apply to UDP. I'd just treat is as an error, and resend entire packet.   ;  Thanks for the reply.Ok so are you saying that the OS layer will simply drop incomplete packets ?   ;  For UDP, the sending machine will either send the entire packet, or no packet at all. If there is enough queuing space in the kernel, sendto() will copy the entire packet into the outgoing queue, and then return. If there is not enough queuing space, sendto() will either block until there is (for a blocking socket), or it will immediately return, having sent nothing (for a non-blocking socket).For TCP, send() (or sendto()) may send less if there's less space available in the kernel outgoing queue. The only time send() or sendto() will block for TCP is when there are 0 bytes left in the queue on a blocking socket -- at that point, they will wait until at least one byte has been queued before returning.;Quote:Original post by hplus0603If there is not enough queuing space, sendto() will either block until there is (for a blocking socket), or it will immediately return, having sent nothing (for a non-blocking socket).So, since I'm polling my socket with select() for writability, i can be assured that my next sendto() call will succeed ?And as Antheus stated, if i don't get 512 byte as a return value when I send 512, I can threat it as an error ?Thanks guys for the clarifications.;  Yes, that is the whole point of select().If you are using UDP, and are getting a value back other than the length you put in, you can treat it as an error.   ;  Big thanks to both of you. Rating++;   