title: Converting an IP Address string to exactly 4 bytes in Python
body: <p>So this is very simple, but I'm having trouble getting this to work.  I want to, for example, if the incoming IP address string is '168.108.114.22', convert this to a bytes object like:</p>
  
  <pre><code>\xA8\x6C\x72\x16
  </code></pre>
  
  <p>Basically each part of the IP address is converted to it's hexadecimal equivalent.  </p>
  
  <p>I've tried so many ways but couldn't get what I want.  String manipulation, using socket.inet_aton, packing, etc.  I want to be able to send  these bytes over a socket and then receive and parse them at the other end, but I am having trouble just getting my bytes object created and looking like that.</p>