title: How do I send a UDP packet with an exact size?
body: <p>I have a simple client/server program in Python, using UDP. I need to send packets with a message of exactly 120 bytes in size plus the header. (Total packet size is <code>120 + sizeof(header)</code>.)</p>
  
  <p>How should I do that? What should the contents of <code>MESSAGE</code> be?</p>
  
  <p>My code:</p>
  
  <pre><code>MESSAGE = "?120B?"
  
  sock = socket.socket(socket.AF_INET, 
                       socket.SOCK_DGRAM) 
  sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
  </code></pre>