Client network message fixes

This commit is contained in:
simon.kagstrom 2010-02-21 18:42:56 +00:00
parent 401784e95e
commit cf043c2fa5

View File

@ -587,25 +587,18 @@ bool Network::SendUpdateDirect(struct sockaddr_in *addr, NetworkUpdate *src)
{ {
uint8_t *p = (uint8_t *)src; uint8_t *p = (uint8_t *)src;
size_t sz; size_t sz;
ssize_t v;
sz = src->size + sizeof(NetworkUpdate); /* stop */ sz = ntohl(src->size) + sizeof(NetworkUpdate); /* stop */
if (sz <= 0) if (sz <= 0)
return false; return false;
size_t cur_sz = 0; printf("Sending %d bytes\n", sz);
do
{
size_t size_to_send = this->FillNetworkBuffer((NetworkUpdate*)p);
ssize_t v;
v = this->SendTo((void*)p, this->sock, v = this->SendTo((void*)p, this->sock,
size_to_send, addr); sz, addr);
if (v <= 0 || (size_t)v != size_to_send) if (v <= 0 || (size_t)v != sz)
return false; return false;
cur_sz += size_to_send; this->traffic += sz;
p += size_to_send;
} while (cur_sz < sz);
this->traffic += cur_sz;
return true; return true;
} }