All pastes #452282 Raw Edit

Stuff

public text v1 · immutable
·published 2007-04-22 04:31 UTC
rendered paste body
static int client_udp_receive(reply_message *mesg)
{
   if (mesg == NULL)
      return -1;

   int length = 0;
   char *datagram = (char*) malloc(65536);
   if (datagram == NULL)
      return -1;

   length = recvfrom(socket_in, datagram, 65536, 0, NULL, NULL);
   if (length == -1)
      return -1;

   memcpy(&mesg->hdr, datagram, sizeof(reply_message_header));
   ntoh_reply_message_header(&mesg->hdr);
   memcpy(mesg->out_data, datagram + sizeof(reply_message_header), length - sizeof(reply_message_header));

   return 0;
}