title: python raw socket: Protocol not supported
body: <p>I am trying to open a raw socket with Python under linux.</p>
  
  <p>My simple code:</p>
  
  <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
  s.bind((HOST, 5454))
  </code></pre>
  
  <p>And I got this error:</p>
  
  <pre><code>[ERROR] Protocol not supported
  </code></pre>
  
  <p>By the way, I am using python 2.7.3 under linux 12.04, and I used root to run the code.</p>
  
  <p>Does anyone have a clue?</p>
  
  <p><strong>Update</strong>: <a href="https://stackoverflow.com/a/19732282/8414561">The solution</a> given by <a href="https://stackoverflow.com/users/1084684/dstromberg">dstromberg</a> is correct. If you want the whole packet, then use his solution. However, there is another combination:</p>
  
  <pre><code>s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
  </code></pre>
  
  <p>that also works.</p>
  
  <p>In this case, you will receive a whole TCP packet with IP and TCP headers on it.
  If your use <a href="https://stackoverflow.com/users/1084684/dstromberg">dstromberg</a>'s solution, you will also see the ethernet header. So it depends on how 'raw' you want your packet to be.</p>