title: Get time/date from server with sntp(windows c++)
body: <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>
  
  <p>If found this:</p>
  
  <pre><code>import socket
  import struct
  import sys
  import time
  
  TIME1970 = 2208988800L      # Thanks to F.Lundh
  
  client = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
  data = '\x1b' + 47 * '\0'
  client.sendto( data, ( sys.argv[1], 123 ))
  data, address = client.recvfrom( 1024 )
  if data:
      print 'Response received from:', address
      t = struct.unpack( '!12I', data )[10]
      t -= TIME1970
      print '\tTime=%s' % time.ctime(t)
  </code></pre>
  
  <p>But it is in python. Can someone change this to c++ or is there a converter for this??</p>