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 7553065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:56:52+00:00 2026-05-30T10:56:52+00:00

I tried – for the first time – to control a socket by such

  • 0

I tried – for the first time – to control a socket by such a low level way
Walking through tutorial, I faced these lines :

byte[] byTrue = new byte [4] {1, 0, 0, 0};
byte[] byOut = new byte [4] {1, 0, 0, 0};

_Socket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);  

I referred to the MSDN documentation, but it’s really very ambiguous.

Question:

What are these 2 bytes’ arrays? What are they used in?
The documentation says OPTIONS – what options?

  • 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-30T10:56:53+00:00Added an answer on May 30, 2026 at 10:56 am

    The byte array arguments to Socket.IOControl() are specific to the IOControlCode that is specified as the first argument.

    The first array is for input data, the second array is for output data.

    To find more information about the specific layout for these arrays, it is helpful to start by looking at the enumeration, which lists all the possible operations for you. From there, you should cross reference with the documentation listed for the C-operable functions that Socket.IOControl() wraps. These are WSAIoctl() and ioctlsocket().

    IOControlCode Enumeration @ MSDN

    WSAIoctl() function @ MSDN
    ioctlsocket() function @ MSDN

    Per the documentation for IOControlCode.ReceiveAll:

    Enable receiving all IPv4 packets on the network. The socket must have
    address family InterNetwork, the socket type must be Raw, and the
    protocol type must be IP. The current user must belong to the
    Administrators group on the local computer, and the socket must be
    bound to a specific port. This control code is supported on Windows
    2000 and later operating systems. This value is equal to the Winsock 2
    SIO_RCVALL constant.

    Cross referencing SIO_RCVALL, we find it has an entry in the winsock documentation.

    SIO_RCVALL control code @ MSDN

    Reading through this entry, it mentions that the input buffer is required to select a mode of operation, with minimum size corresponding to a RCVALL_VALUE. In your statement you are passing the value 1 in the input argument array. We can check header files to see what this should mean.

    You should double check this with C header files at hand, but the interface-compatible copy for wine (windows emulator) says the value for mode RCVALL_ON is 1. The .NET method should wrap the details of managing array size for you, so the code snippet you encountered is trying to enable RCVALL_ON for the socket.

    Here is the link to the C header file at winehq.org:
    mstcpip.h at winehq.org

    If you’ve installed C/C++ support for visual studio, you may be able to locate mstcpip.h and winsock2.h locally at a path similar to the following:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\
    

    My copy says:

    //
    // Values for use with SIO_RCVALL* options
    //
    typedef enum {
        RCVALL_OFF             = 0,
        RCVALL_ON              = 1,
        RCVALL_SOCKETLEVELONLY = 2,
        RCVALL_IPLEVEL         = 3,
    } RCVALL_VALUE, *PRCVALL_VALUE;
    

    I couldn’t find any documentation that specifically says what size byte array should be used to pass a RCVALL_VALUE, but if you look at the the samples for IOControl(), they use BitConverter.GetBytes(0) for default parameters which would have a size of 4 bytes (corresponding to a .NET int) and matches your example. This is large enough to fit a RCVALL_VALUE in C operation as well.

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

Sidebar

Related Questions

Tried to fiddle with knockoutjs for the first time, but can't get any examples
Tried to sift through the google results; no luck. What I'm trying to do
Tried to map it from Preferences -> Settings -> Keyboard, but the key combo
Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
Tried following the instructions here: How to use Google app engine with my own
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Tried a bunch of things but I can't get it to work consistently amid
tried to find the answer by googling and in MSDN but with no luck.
Tried to make a little old school ajax (iframe-javascript) script. A bit of mootools
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']

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.