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