title: DHCP : Cant receive reply from server
body: <p>I am working on Ubuntu 9.04. I am running this on VMware workstation. Here is my C code:</p>
  
  <pre><code>int sockfd,cnt,addrlen;
  const int on = 1;
  struct sockaddr_in servaddr,cliaddr;
  char reply[512];
  
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  
  if (sockfd &lt; 0) {
     perror("socket");
     exit(1);
  }
  
  setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR, &amp;on,sizeof(on));
  bzero(&amp;cliaddr, sizeof(cliaddr));
  cliaddr.sin_family = AF_INET;
  cliaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  cliaddr.sin_port = htons(68);
  addrlen = sizeof(servaddr);
  
  if (bind(sockfd, (struct sockaddr *) &amp;cliaddr, sizeof(cliaddr)) &lt; 0) {        
    perror("bind");
    exit(1);
  } 
  
  while(1)
  {       
     cnt = recvfrom(sockfd, reply, sizeof(reply), 0,(struct sockaddr *) &amp;servaddr, &amp;addrlen);
  
     if (cnt &lt; 0) {
       perror("recvfrom");
       exit(1);
     } 
  
     printf("\nReply Received\n");
  }
  </code></pre>
  
  <p>I run this program in one terminal and run 'dhclient' on another. I receive no datagrams. What am I doing wrong?</p>