Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7075609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:11:53+00:00 2026-05-28T06:11:53+00:00

Let me state up front, that sockets programming is fairly new to me. Also,

  • 0

Let me state up front, that sockets programming is fairly new to me. Also, the code I’m asking about has worked for several years and the problem I discuss only began when we changed from supporting Windows XP to Windows 7.

I am working on a C# application that sends and receives network packets. It’s sort of a network sniffer type application, so data integrity is very important. Ever since we migrated from Windows XP to Windows 7, when we UDP Broadcast (255.255.255.255) packets, we receive the packets twice. (i.e. I send 610 packets, I receive 1220 packets).

I have verified with WireShark that the packets are only being received once. Also, we have some older C++ sockets code that had been replaced by .NET code. The older C++ code does not indicate duplicates. These both indicate 610 packets sent, 610 packets received.

The code is highly threaded and split among various classes, but putting some of the pieces together, the receive code looks like the following:

public class RawSocket : Socket
{
    public RawSocket( IPAddress address, int receiveBufferSize, bool receiveAll )
        : base( AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP )
    {
        Bind( new IPEndPoint( address, 0 ) );

        ReceiveBufferSize = receiveBufferSize;

        ReceiveTimeout = 500; // half-a-second

        if ( receiveAll ) {
            byte[] incoming = BitConverter.GetBytes( 1 );
            byte[] outgoing = BitConverter.GetBytes( 1 );
            IOControl( IOControlCode.ReceiveAll, incoming, outgoing );
        }
    }
}

_device = new RawSocket( /* IP Address Specified Here */ );

And then in the code responsible for reading…

byte[] buffer = new byte[ 65536 ];
int read = _device.Receive( buffer );
if (read > 0)
{
    _packet = new byte[ size ];
    _packet.BlockCopy( buffer, offset, size );
}

So my question is, what changed with the .NET sockets API between Windows XP and Windows 7 that would cause this behavior? I have read threads that indicate there are differences, but nothing like this. Tracing through the code makes me think that it has to do with the behavior of the Receive() method on the Socket class that may be different. Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:11:53+00:00Added an answer on May 28, 2026 at 6:11 am

    According to the spec this is expected behaviour.

    http://msdn.microsoft.com/en-us/library/system.net.sockets.iocontrolcode(v=vs.110).aspx says that ReceiveAll equals to the Winsock 2 SIO_RCVALL constant.

    http://msdn.microsoft.com/en-us/library/windows/desktop/ee309610(v=vs.85).aspx says:

    On Windows Server 2008 and earlier, the SIO_RCVALL IOCTL setting would
    not capture local packets sent out of a network interface. This
    included packets received on another interface and forwarded out the
    network interface specified for the SIO_RCVALL IOCTL.

    On Windows 7
    and Windows Server 2008 R2 , this was changed so that local packets
    sent out of a network interface are also captured. This includes
    packets received on another interface and then forwarded out the
    network interface bound to the socket with SIO_RCVALL IOCTL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First let me state that, despite being a fairly new practitioner of TDD, I'm
Let me state up front that I have an infantile understanding of Monads. I
First, let me state that this is a programming question (and thus does not
Ok first off let me state that I am new to PHP. So What
Let me first state that I know next to nothing about LDAP and this
Let me state first: I know that any user that wants to run a
Let me state off the bat that I'm not that familiar with ASP.Net MVC,
In DDD you should never let your entities enter an invalid state. That being
First, let me state what brought this question about: I saw the green checkmark
First let me just state that coding without unit testing is just plain crazy.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.