The Labs \ Source Viewer \ SSCLI \ System.Net.Sockets \ AsyncEventBitsPos

  1. //------------------------------------------------------------------------------
  2. // <copyright file="Internal.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net.Sockets
  16. {
  17.     using System;
  18.     using System.Collections;
  19.     using System.Configuration;
  20.     using System.Configuration.Assemblies;
  21.     using System.Diagnostics;
  22.     using System.Globalization;
  23.     using System.IO;
  24.     using System.Net;
  25.     using System.Net.Sockets;
  26.     using System.Reflection;
  27.     using System.Reflection.Emit;
  28.     using System.Resources;
  29.     using System.Runtime.InteropServices;
  30.     using System.Runtime.Serialization;
  31.     using System.Runtime.Serialization.Formatters;
  32.     using System.Security;
  33.     using System.Security.Cryptography;
  34.     using System.Security.Cryptography.X509Certificates;
  35.     using System.Security.Permissions;
  36.     using System.Text;
  37.     using System.Text.RegularExpressions;
  38.     using System.Threading;
  39.    
  40.     //
  41.     // IO-Control operations are not directly exposed.
  42.     // blocking is controlled by "Blocking" property on socket (FIONBIO)
  43.     // amount of data available is queried by "Available" property (FIONREAD)
  44.     // The other flags are not exposed currently
  45.     //
  46.     static internal class IoctlSocketConstants
  47.     {
  48.        
  49.         public const int FIONREAD = 1074030207;
  50.         public const int FIONBIO = unchecked((int)2147772030u);
  51.         public const int FIOASYNC = unchecked((int)2147772029u);
  52.         public const int SIOGETEXTENSIONFUNCTIONPOINTER = unchecked((int)3355443206u);
  53.        
  54.         //
  55.         // not likely to block (sync IO ok)
  56.         //
  57.         // FIONBIO
  58.         // FIONREAD
  59.         // SIOCATMARK
  60.         // SIO_RCVALL
  61.         // SIO_RCVALL_MCAST
  62.         // SIO_RCVALL_IGMPMCAST
  63.         // SIO_KEEPALIVE_VALS
  64.         // SIO_ASSOCIATE_HANDLE (opcode setting: I, T==1)
  65.         // SIO_ENABLE_CIRCULAR_QUEUEING (opcode setting: V, T==1)
  66.         // SIO_GET_BROADCAST_ADDRESS (opcode setting: O, T==1)
  67.         // SIO_GET_EXTENSION_FUNCTION_POINTER (opcode setting: O, I, T==1)
  68.         // SIO_MULTIPOINT_LOOPBACK (opcode setting: I, T==1)
  69.         // SIO_MULTICAST_SCOPE (opcode setting: I, T==1)
  70.         // SIO_TRANSLATE_HANDLE (opcode setting: I, O, T==1)
  71.         // SIO_ROUTING_INTERFACE_QUERY (opcode setting: I, O, T==1)
  72.         //
  73.         // likely to block (reccommended for async IO)
  74.         //
  75.         // SIO_FIND_ROUTE (opcode setting: O, T==1)
  76.         // SIO_FLUSH (opcode setting: V, T==1)
  77.         // SIO_GET_QOS (opcode setting: O, T==1)
  78.         // SIO_GET_GROUP_QOS (opcode setting: O, I, T==1)
  79.         // SIO_SET_QOS (opcode setting: I, T==1)
  80.         // SIO_SET_GROUP_QOS (opcode setting: I, T==1)
  81.         // SIO_ROUTING_INTERFACE_CHANGE (opcode setting: I, T==1)
  82.         // SIO_ADDRESS_LIST_CHANGE (opcode setting: T==1)
  83.     }
  84.    
  85.     //
  86.     // WinSock 2 extension -- bit values and indices for FD_XXX network events
  87.     //
  88.     [Flags()]
  89.     internal enum AsyncEventBits
  90.     {
  91.         FdNone = 0,
  92.         FdRead = 1 << 0,
  93.         FdWrite = 1 << 1,
  94.         FdOob = 1 << 2,
  95.         FdAccept = 1 << 3,
  96.         FdConnect = 1 << 4,
  97.         FdClose = 1 << 5,
  98.         FdQos = 1 << 6,
  99.         FdGroupQos = 1 << 7,
  100.         FdRoutingInterfaceChange = 1 << 8,
  101.         FdAddressListChange = 1 << 9,
  102.         FdAllEvents = (1 << 10) - 1
  103.     }
  104.    
  105.     // Array position in NetworkEvents (WSAEnumNetworkEvents).
  106.     internal enum AsyncEventBitsPos
  107.     {
  108.         FdReadBit = 0,
  109.         FdWriteBit = 1,
  110.         FdOobBit = 2,
  111.         FdAcceptBit = 3,
  112.         FdConnectBit = 4,
  113.         FdCloseBit = 5,
  114.         FdQosBit = 6,
  115.         FdGroupQosBit = 7,
  116.         FdRoutingInterfaceChangeBit = 8,
  117.         FdAddressListChangeBit = 9,
  118.         FdMaxEvents = 10
  119.     }
  120.    
  121.     [StructLayout(LayoutKind.Sequential)]
  122.     internal struct NetworkEvents
  123.     {
  124.         //
  125.         // Indicates which of the FD_XXX network events have occurred.
  126.         //
  127.         public AsyncEventBits Events;
  128.        
  129.         //
  130.         // An array that contains any associated error codes, with an array index that corresponds to the position of event bits in lNetworkEvents. The identifiers FD_READ_BIT, FD_WRITE_BIT and other can be used to index the iErrorCode array.
  131.         //
  132.         [MarshalAs(UnmanagedType.ByValArray, SizeConst = (int)AsyncEventBitsPos.FdMaxEvents)]
  133.         public int[] ErrorCodes;
  134.     }
  135.    
  136.     //
  137.     // Structure used in select() call, taken from the BSD file sys/time.h.
  138.     //
  139.     [StructLayout(LayoutKind.Sequential)]
  140.     internal struct TimeValue
  141.     {
  142.         public int Seconds;
  143.         // seconds
  144.         public int Microseconds;
  145.         // and microseconds
  146.     }
  147.     // struct TimeValue
  148. }
  149. // namespace System.Net.Sockets

Developer Fusion