title: Can't receive packets to raw socket
body: <p>I'm writing raw socket client (which successfully sends UDP packets) and a server socket, The problem is in the server part. </p>
  
  <p>Im creating a socket in the following way:</p>
  
  <p><code>int raw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);</code></p>
  
  <p>also I tried it with IPPROTO_RAW, but get the same result and I'm binding it:</p>
  
  <p><code>bind(raw_socket, (struct sockaddr*)&amp;sockstr, sizeof(sockstr))</code></p>
  
  <p>when trying to receive some packets using the socket, the only payload I receive is "E" (I think that means "Error"), or the socket continues listening but blocks and nothing happens.
  How do I receive a UDP packet using a raw socket?
  My code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;netdb.h&gt;
  #include &lt;netinet/in.h&gt;
  #include &lt;string.h&gt;
  int server(){
      int raw_socket = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
      if (raw_socket== -1){
          perror("Socket_creation_error\n");
          return 1;
      }
  
      struct sockaddr_in sockstr;
      sockstr.sin_addr.s_addr = inet_addr("127.0.0.1");
      sockstr.sin_family = AF_INET;
      sockstr.sin_port = htons(9090);
      socklen_t s = (socklen_t)sizeof(sockstr);
  
      if (bind(raw_socket, (struct sockaddr*)&amp;sockstr, sizeof(sockstr))&lt; 0){
          perror("binding_err\n");
          return 0;
      }
      char* msg[256];
      memset(msg, 0, 256);
  
      recv(raw_socket, msg, sizeof(msg), 0);
      printf(msg);
      return 0;
  }
  
  void main(){
      server();
  }
  </code></pre>