title: c - multiple variables over udp socket
body: <p>I have to send multiple variables types over an udp socket: an int array and a char. I would like to send it on the same udp packet. What is the standard solution? Convert everything to bytes or something similar?</p>
  
  <p>I'm using: sendto(int sockfd, const void *buf, size_t len, int flags,
                        const struct sockaddr *dest_addr, socklen_t addrlen);</p>
  
  <p>My code is something like:</p>
  
  <pre><code>int buffer[100];
  char flag = '0';
  int i = 0;
  
  for (i = 0; i &lt; 50; i++) {
      buffer[i] = i * 2;
  }
  
  if (sendto(s, buffer, sizeof(buffer), 0, (struct sockaddr *) &amp;si_client, slen) == -1 ){
      //error
  }
  
  //rest of the program
  </code></pre>