<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Winsocket RawSocket]]></title><description><![CDATA[<p>also ich hab das problem, dass ich zwar den socket erzeugen kann, aber als rc immer nur -1 krieg, wenn ich recvfrom aufrufe.<br />
Ich habe gelesen, dann ms den rawsocket stark eingeschränkt hat seit dem SP2 für XP, kann es sein dass dann folgender code nciht mehr funktioniert? (der ist grad etwas grausig, liegt daran dass ich da einige verschiedene beispiele versucht hab zum laufen zu bringe.</p>
<pre><code class="language-cpp">int main(int argc, char* argv[])
{
  // The Variables
  UINT Option;
  WORD Version;
  SOCKET Socket;
  WSADATA WSAData;
  SOCKADDR_IN Address;

  char packet[PacketSize] ;

  memset( packet,0 , PacketSize ) ;

  // Show Program Info
  printf(&quot;\n&quot;);
  printf(PROGINFO);
  printf(&quot;\n \n&quot;);

  // Non-Unix Startup Routine
  if (WSAStartup(MAKEWORD(2, 2), &amp;WSAData) != 0)
  {
    printf(&quot;Error: Startup failed. \n&quot;);
    return -1;
  }

  // Zero-Fill Address Struct
  memset(&amp;Address, 0, sizeof(SOCKADDR_IN));

  // Set IPv4 Family

    // Socket Open
    if ( (Socket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) ) == INVALID_SOCKET)
    {
      printf(&quot;Error: Could not create Socket. \n&quot;);
      return -1;
    }

    //// Header Senden aktivieren
    //Option = 1;
    //if (setsockopt(Socket, IPPROTO_IP, IP_HDRINCL, (char *) &amp;Option, sizeof(Option)) != 0)
    //{
    //  printf(&quot;Error: Could not set socket option. \n&quot;);
    //  printf(&quot;%d&quot;, WSAGetLastError());
    //  return -1;
    //}

     char szBuffer[4096];
     SOCKADDR_IN saFrom;

      int nResponseLen = 0;
      int nFromLen = sizeof(saFrom);

      while ( true )
      {
        nResponseLen = recvfrom(Socket, szBuffer, 4096, 0, (SOCKADDR *) &amp;saFrom, &amp;nFromLen);
      }

  // Non-Unix Cleanup Routine
  if (WSACleanup() != 0)
  {
    printf(&quot;Error: Cleanup failed. \n&quot;);
    return -1;
  }

  // Exit
  return 0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/195916/winsocket-rawsocket</link><generator>RSS for Node</generator><lastBuildDate>Mon, 29 Jun 2026 19:49:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195916.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Oct 2007 14:34:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Winsocket RawSocket on Tue, 23 Oct 2007 14:34:27 GMT]]></title><description><![CDATA[<p>also ich hab das problem, dass ich zwar den socket erzeugen kann, aber als rc immer nur -1 krieg, wenn ich recvfrom aufrufe.<br />
Ich habe gelesen, dann ms den rawsocket stark eingeschränkt hat seit dem SP2 für XP, kann es sein dass dann folgender code nciht mehr funktioniert? (der ist grad etwas grausig, liegt daran dass ich da einige verschiedene beispiele versucht hab zum laufen zu bringe.</p>
<pre><code class="language-cpp">int main(int argc, char* argv[])
{
  // The Variables
  UINT Option;
  WORD Version;
  SOCKET Socket;
  WSADATA WSAData;
  SOCKADDR_IN Address;

  char packet[PacketSize] ;

  memset( packet,0 , PacketSize ) ;

  // Show Program Info
  printf(&quot;\n&quot;);
  printf(PROGINFO);
  printf(&quot;\n \n&quot;);

  // Non-Unix Startup Routine
  if (WSAStartup(MAKEWORD(2, 2), &amp;WSAData) != 0)
  {
    printf(&quot;Error: Startup failed. \n&quot;);
    return -1;
  }

  // Zero-Fill Address Struct
  memset(&amp;Address, 0, sizeof(SOCKADDR_IN));

  // Set IPv4 Family

    // Socket Open
    if ( (Socket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) ) == INVALID_SOCKET)
    {
      printf(&quot;Error: Could not create Socket. \n&quot;);
      return -1;
    }

    //// Header Senden aktivieren
    //Option = 1;
    //if (setsockopt(Socket, IPPROTO_IP, IP_HDRINCL, (char *) &amp;Option, sizeof(Option)) != 0)
    //{
    //  printf(&quot;Error: Could not set socket option. \n&quot;);
    //  printf(&quot;%d&quot;, WSAGetLastError());
    //  return -1;
    //}

     char szBuffer[4096];
     SOCKADDR_IN saFrom;

      int nResponseLen = 0;
      int nFromLen = sizeof(saFrom);

      while ( true )
      {
        nResponseLen = recvfrom(Socket, szBuffer, 4096, 0, (SOCKADDR *) &amp;saFrom, &amp;nFromLen);
      }

  // Non-Unix Cleanup Routine
  if (WSACleanup() != 0)
  {
    printf(&quot;Error: Cleanup failed. \n&quot;);
    return -1;
  }

  // Exit
  return 0;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1390603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1390603</guid><dc:creator><![CDATA[Jason_Frost]]></dc:creator><pubDate>Tue, 23 Oct 2007 14:34:27 GMT</pubDate></item><item><title><![CDATA[Reply to Winsocket RawSocket on Tue, 23 Oct 2007 14:59:22 GMT]]></title><description><![CDATA[<p>Bringt eventuell WSAGetLastError() noch brauchbare Infos?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1390628</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1390628</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Tue, 23 Oct 2007 14:59:22 GMT</pubDate></item><item><title><![CDATA[Reply to Winsocket RawSocket on Tue, 23 Oct 2007 15:22:11 GMT]]></title><description><![CDATA[<p>liefert WSAEINVAL zurück <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f611.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--expressionless_face"
      title="-_-"
      alt="😑"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1390653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1390653</guid><dc:creator><![CDATA[Jason_Frost]]></dc:creator><pubDate>Tue, 23 Oct 2007 15:22:11 GMT</pubDate></item><item><title><![CDATA[Reply to Winsocket RawSocket on Wed, 24 Oct 2007 08:19:05 GMT]]></title><description><![CDATA[<p>MSDN schrieb:</p>
<blockquote>
<p>Restricted traffic over raw sockets<br />
Detailed description</p>
<p>A very small number of Windows applications make use of raw IP sockets, which provide an industry-standard way for applications to create TCP/IP packets with fewer integrity and security checks by the TCP/IP stack. The Windows implementation of TCP/IP still supports receiving traffic on raw IP sockets. However, the ability to send traffic over raw sockets has been restricted in two ways:</p>
<p>- TCP data cannot be sent over raw sockets.</p>
<p>- UDP datagrams with invalid source addresses cannot be sent over raw sockets. The IP source address for any outgoing UDP datagram must exist on a network interface or the datagram is dropped.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1391002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391002</guid><dc:creator><![CDATA[msdn]]></dc:creator><pubDate>Wed, 24 Oct 2007 08:19:05 GMT</pubDate></item></channel></rss>