title: sntp client in c++ for time/date
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/9326677/is-there-any-c-c-library-to-connect-with-a-remote-ntp-server">Is there any C/C++ library to connect with a remote NTP server?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm searching for a working code in c/c++ that gets the time and date from the server(ntp.belnet.be). It works with UDP and uses port 123.</p>
  
  <p>Can someone help?</p>
  
  <pre><code>//sending pakket
  memset(&amp;sntp_msg_header, 0, sizeof sntp_msg_header);
  sntp_msg_header.flags = 27;
  sntp_msg_header.originate_timestamp_secs = time(NULL);
  
  // Get data in rxmsg
  ...
  ...
  
  // print time
  timeval = ntohl(rxmsg.transmit_timestamp_secs) - ((70ul * 365ul + 17ul) * 86400ul);
  printf("%s", ctime(&amp;timeval));
  </code></pre>
  
  <p>This is what i have so far. But i can't get the correct data out of it.
  I hope this is more information.</p>