title: python icmp raw socket implementation
body: <p>i am relatively new to python, so please be considerate...</p>
  
  <p>i'm implementing a server and a client via raw_sockets.
  i have the necessary privileges.</p>
  
  <p>now, the <strong>server</strong> i defined so:</p>
  
  <pre><code>host = socket.gethostbyname(socket.gethostname())
  address = (host, 22224)
  sockSer = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
  sockSer.bind(address)
  sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
  packet, addr = sockSer .recvfrom(4096)   # wait for packet from client
  </code></pre>
  
  <p><strong>Q1)</strong> why can't i simply type: hosts = 'localhost'.
  if i do so, it doesn't allow me to write the line: sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON). and then the server doesn't receive my client's messages.
  only when doing gethostbyname(socket.gethostname()) i get 192.168.1.101 
  and then it works.</p>
  
  <p>in a different class:
  the <strong>client</strong> socket:</p>
  
  <pre><code>host = socket.gethostbyname(socket.gethostname())
  address = (host, 22224)
  sockCli = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
  </code></pre>
  
  <p><strong>Q2)</strong> do i also need to type: sockCli.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
  or maybe sockCli.connect(address)? seems that it works without the connect command. 
  for the client socket? </p>
  
  <p>now, the problems arise when i do the following:
  1) send a packet from client to server:</p>
  
  <pre><code>header=...
  payload='a'
  sockCli.sendto(header + payload, address)
  </code></pre>
  
  <p>2) receive packet in server and send something back to client:</p>
  
  <pre><code>while(true):
      data, addr = sockSer.recvfrom(4096)
      header2=...
      payload2='b'
      sockSer.sendto(header2 + payload2, addr)
  </code></pre>
  
  <p>now, my important question is:
  <strong>Q3)</strong> the server sent only 1 packet to client, with payload 'b'.
  what happens is, my client actually receives 2 packets in the while loop:
  first packet is what <strong>the client itself sent to server</strong>, and the other packet is what the client got from the server.
  hence my output is 'ab' instead of simply 'b'
  why is this happening???</p>
  
  <p>NOTE: i didn't type the entire code, but i think my syntax,parsing,header composition etc.. are correct.
  is there an obvious problem in my code?
  if necessary i'll upload the entire code.</p>
  
  <p>thanks </p>