title: UDP client on a OS X
body: <p>I wanted to compile sample code for a UDP client on a Mac OS X, but got a following error:</p>
  
  <pre><code>client.c:91:9: error: use of undeclared identifier 'MSG_CONFIRM'
          MSG_CONFIRM, (const struct sockaddr *) &amp;servaddr,
          ^
  </code></pre>
  
  <p>I googled for the error for several hours but couldn't find anything related to this problem.  Does anybody know what is the issue and how to fix it?</p>
  
  <p>The code for UDP client is below</p>
  
  <pre><code>// Client side implementation of UDP client-server model
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/socket.h&gt;
  #include &lt;arpa/inet.h&gt;
  #include &lt;netinet/in.h&gt;
  #include &lt;netdb.h&gt;
  
  #define PORT     8080
  #define MAXLINE 1024
  
  // Driver code
  int main() {
      int sockfd;
      char buffer[MAXLINE];
      char *hello = "Hello from client";
      struct sockaddr_in     servaddr;
  
      // Creating socket file descriptor
      if ( (sockfd = socket(AF_INET, SOCK_DGRAM, 0)) &lt; 0 ) {
          perror("socket creation failed");
          exit(EXIT_FAILURE);
      }
  
      memset(&amp;servaddr, 0, sizeof(servaddr));
  
      // Filling server information
      servaddr.sin_family = AF_INET;
      servaddr.sin_port = htons(PORT);
      servaddr.sin_addr.s_addr = INADDR_ANY;
  
      int n, len;
  
      sendto(sockfd, (const char *)hello, strlen(hello),
          MSG_CONFIRM, (const struct sockaddr *) &amp;servaddr,
              sizeof(servaddr));
      printf("Hello message sent.\n");
  
      while (1)
      {
          n = recvfrom(sockfd, (char *)buffer, MAXLINE,
                  MSG_WAITALL, (struct sockaddr *) &amp;servaddr,
                  &amp;len);
          buffer[n] = '\0';
          printf("Server : %s\n", buffer);
      }
  
      close(sockfd);
      return 0;
  }
  </code></pre>