477 references to Interop
System.Net.Sockets (477)
LibraryImports.g.cs (11)
71
private static partial int PathConf(string path, global::
Interop
.Sys.PathConfName name)
100
static extern unsafe int __PInvoke(byte* __path_native, global::
Interop
.Sys.PathConfName __name_native);
109
internal static partial int FStat(global::System.Runtime.InteropServices.SafeHandle fd, out global::
Interop
.Sys.FileStatus output)
122
fixed (global::
Interop
.Sys.FileStatus* __output_native = &output)
141
static extern unsafe int __PInvoke(nint __fd_native, global::
Interop
.Sys.FileStatus* __output_native);
150
internal static partial int Stat(string path, out global::
Interop
.Sys.FileStatus output)
163
fixed (global::
Interop
.Sys.FileStatus* __output_native = &output)
182
static extern unsafe int __PInvoke(byte* __path_native, global::
Interop
.Sys.FileStatus* __output_native);
191
internal static partial int LStat(string path, out global::
Interop
.Sys.FileStatus output)
204
fixed (global::
Interop
.Sys.FileStatus* __output_native = &output)
223
static extern unsafe int __PInvoke(byte* __path_native, global::
Interop
.Sys.FileStatus* __output_native);
src\libraries\Common\src\Interop\Unix\Interop.Errors.cs (6)
124
_error =
Interop
.Sys.ConvertErrorPlatformToPal(errno);
141
get { return _rawErrno == -1 ? (_rawErrno =
Interop
.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; }
146
return
Interop
.Sys.StrError(RawErrno);
220
public static
Interop
.ErrorInfo Info(this
Interop
.Error error)
222
return new
Interop
.ErrorInfo(error);
src\libraries\Common\src\System\Net\InteropIPAddressExtensions.Unix.cs (6)
11
public static unsafe
Interop
.Sys.IPAddress GetNativeIPAddress(this IPAddress ipAddress)
13
var nativeIPAddress = default(
Interop
.Sys.IPAddress);
15
ipAddress.TryWriteBytes(new Span<byte>(nativeIPAddress.Address,
Interop
.Sys.IPv6AddressBytes), out int bytesWritten);
16
Debug.Assert(bytesWritten == sizeof(uint) || bytesWritten ==
Interop
.Sys.IPv6AddressBytes, $"Unexpected length: {bytesWritten}");
27
public static unsafe IPAddress GetIPAddress(this
Interop
.Sys.IPAddress nativeIPAddress)
37
new ReadOnlySpan<byte>(nativeIPAddress.Address,
Interop
.Sys.IPv6AddressBytes),
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (23)
26
Interop
.Error err =
Interop
.Sys.GetSocketAddressSizes(&ipv4, &ipv6, &uds, &max);
27
Debug.Assert(err ==
Interop
.Error.SUCCESS, $"Unexpected err: {err}");
39
private static void ThrowOnFailure(
Interop
.Error err)
43
case
Interop
.Error.SUCCESS:
46
case
Interop
.Error.EFAULT:
50
case
Interop
.Error.EAFNOSUPPORT:
63
Interop
.Error err;
66
err =
Interop
.Sys.GetAddressFamily(rawAddress, buffer.Length, (int*)&family);
75
Interop
.Error err;
81
err =
Interop
.Sys.SetAddressFamily(rawAddress, buffer.Length, (int)family);
91
Interop
.Error err;
94
err =
Interop
.Sys.GetPort(rawAddress, buffer.Length, &port);
103
Interop
.Error err;
106
err =
Interop
.Sys.SetPort(rawAddress, buffer.Length, port);
115
Interop
.Error err;
118
err =
Interop
.Sys.GetIPv4Address(rawAddress, buffer.Length, &ipAddress);
128
Interop
.Error err;
132
err =
Interop
.Sys.GetIPv6Address(rawAddress, buffer.Length, ipAddress, address.Length, &localScope);
141
Interop
.Error err;
144
err =
Interop
.Sys.SetIPv4Address(rawAddress, buffer.Length, address);
167
Interop
.Error err;
170
err =
Interop
.Sys.SetIPv6Address(rawAddress, buffer.Length, address, addressLength, scope);
src\libraries\Common\src\System\Net\SocketProtocolSupportPal.Unix.cs (5)
25
Interop
.Error result =
Interop
.Sys.Socket((int)af, DgramSocketType, 0, &socket);
27
return result !=
Interop
.Error.EAFNOSUPPORT && result !=
Interop
.Error.EPROTONOSUPPORT;
33
Interop
.Sys.Close(socket);
src\libraries\Common\src\System\Net\Sockets\SocketErrorPal.Unix.cs (92)
20
internal static SocketError GetSocketErrorForNativeError(
Interop
.Error errno) => errno switch
22
Interop
.Error.EACCES => SocketError.AccessDenied,
23
Interop
.Error.EADDRINUSE => SocketError.AddressAlreadyInUse,
24
Interop
.Error.EADDRNOTAVAIL => SocketError.AddressNotAvailable,
25
Interop
.Error.EAFNOSUPPORT => SocketError.AddressFamilyNotSupported,
26
Interop
.Error.EAGAIN => SocketError.WouldBlock,
27
Interop
.Error.EALREADY => SocketError.AlreadyInProgress,
28
Interop
.Error.EBADF => SocketError.OperationAborted,
29
Interop
.Error.ECANCELED => SocketError.OperationAborted,
30
Interop
.Error.ECONNABORTED => SocketError.ConnectionAborted,
31
Interop
.Error.ECONNREFUSED => SocketError.ConnectionRefused,
32
Interop
.Error.ECONNRESET => SocketError.ConnectionReset,
33
Interop
.Error.EDESTADDRREQ => SocketError.DestinationAddressRequired,
34
Interop
.Error.EFAULT => SocketError.Fault,
35
Interop
.Error.EHOSTDOWN => SocketError.HostDown,
36
Interop
.Error.ENXIO => SocketError.HostNotFound, // not perfect, but closest match available
37
Interop
.Error.EHOSTUNREACH => SocketError.HostUnreachable,
38
Interop
.Error.EINPROGRESS => SocketError.InProgress,
39
Interop
.Error.EINTR => SocketError.Interrupted,
40
Interop
.Error.EINVAL => SocketError.InvalidArgument,
41
Interop
.Error.EISCONN => SocketError.IsConnected,
42
Interop
.Error.EMFILE => SocketError.TooManyOpenSockets,
43
Interop
.Error.EMSGSIZE => SocketError.MessageSize,
44
Interop
.Error.ENETDOWN => SocketError.NetworkDown,
45
Interop
.Error.ENETRESET => SocketError.NetworkReset,
46
Interop
.Error.ENETUNREACH => SocketError.NetworkUnreachable,
47
Interop
.Error.ENFILE => SocketError.TooManyOpenSockets,
48
Interop
.Error.ENOBUFS => SocketError.NoBufferSpaceAvailable,
49
Interop
.Error.ENODATA => SocketError.NoData,
50
Interop
.Error.ENOENT => SocketError.AddressNotAvailable,
51
Interop
.Error.ENOPROTOOPT => SocketError.ProtocolOption,
52
Interop
.Error.ENOTCONN => SocketError.NotConnected,
53
Interop
.Error.ENOTSOCK => SocketError.NotSocket,
54
Interop
.Error.ENOTSUP => SocketError.OperationNotSupported,
55
Interop
.Error.EPERM => SocketError.AccessDenied,
56
Interop
.Error.EPIPE => SocketError.Shutdown,
57
Interop
.Error.EPFNOSUPPORT => SocketError.ProtocolFamilyNotSupported,
58
Interop
.Error.EPROTONOSUPPORT => SocketError.ProtocolNotSupported,
59
Interop
.Error.EPROTOTYPE => SocketError.ProtocolType,
60
Interop
.Error.ESOCKTNOSUPPORT => SocketError.SocketNotSupported,
61
Interop
.Error.ESHUTDOWN => SocketError.Disconnecting,
62
Interop
.Error.SUCCESS => SocketError.Success,
63
Interop
.Error.ETIMEDOUT => SocketError.TimedOut,
67
private static
Interop
.Error GetNativeErrorForSocketErrorHelper(SocketError error) => error switch
75
SocketError.AccessDenied =>
Interop
.Error.EACCES, // could also have been EPERM
76
SocketError.AddressAlreadyInUse =>
Interop
.Error.EADDRINUSE,
77
SocketError.AddressNotAvailable =>
Interop
.Error.EADDRNOTAVAIL,
78
SocketError.AddressFamilyNotSupported =>
Interop
.Error.EAFNOSUPPORT,
79
SocketError.AlreadyInProgress =>
Interop
.Error.EALREADY,
80
SocketError.ConnectionAborted =>
Interop
.Error.ECONNABORTED,
81
SocketError.ConnectionRefused =>
Interop
.Error.ECONNREFUSED,
82
SocketError.ConnectionReset =>
Interop
.Error.ECONNRESET,
83
SocketError.DestinationAddressRequired =>
Interop
.Error.EDESTADDRREQ,
84
SocketError.Disconnecting =>
Interop
.Error.ESHUTDOWN,
85
SocketError.Fault =>
Interop
.Error.EFAULT,
86
SocketError.HostDown =>
Interop
.Error.EHOSTDOWN,
87
SocketError.HostNotFound =>
Interop
.Error.EHOSTNOTFOUND,
88
SocketError.HostUnreachable =>
Interop
.Error.EHOSTUNREACH,
89
SocketError.InProgress =>
Interop
.Error.EINPROGRESS,
90
SocketError.Interrupted =>
Interop
.Error.EINTR,
91
SocketError.InvalidArgument =>
Interop
.Error.EINVAL,
92
SocketError.IOPending =>
Interop
.Error.EINPROGRESS,
93
SocketError.IsConnected =>
Interop
.Error.EISCONN,
94
SocketError.MessageSize =>
Interop
.Error.EMSGSIZE,
95
SocketError.NetworkDown =>
Interop
.Error.ENETDOWN,
96
SocketError.NetworkReset =>
Interop
.Error.ENETRESET,
97
SocketError.NetworkUnreachable =>
Interop
.Error.ENETUNREACH,
98
SocketError.NoBufferSpaceAvailable =>
Interop
.Error.ENOBUFS,
99
SocketError.NoData =>
Interop
.Error.ENODATA,
100
SocketError.NotConnected =>
Interop
.Error.ENOTCONN,
101
SocketError.NotSocket =>
Interop
.Error.ENOTSOCK,
102
SocketError.OperationAborted =>
Interop
.Error.ECANCELED,
103
SocketError.OperationNotSupported =>
Interop
.Error.ENOTSUP,
104
SocketError.ProtocolFamilyNotSupported =>
Interop
.Error.EPFNOSUPPORT,
105
SocketError.ProtocolNotSupported =>
Interop
.Error.EPROTONOSUPPORT,
106
SocketError.ProtocolOption =>
Interop
.Error.ENOPROTOOPT,
107
SocketError.ProtocolType =>
Interop
.Error.EPROTOTYPE,
108
SocketError.Shutdown =>
Interop
.Error.EPIPE,
109
SocketError.SocketNotSupported =>
Interop
.Error.ESOCKTNOSUPPORT,
110
SocketError.Success =>
Interop
.Error.SUCCESS,
111
SocketError.TimedOut =>
Interop
.Error.ETIMEDOUT,
112
SocketError.TooManyOpenSockets =>
Interop
.Error.ENFILE, // could also have been EMFILE
113
SocketError.TryAgain =>
Interop
.Error.EAGAIN, // not a perfect mapping, but better than nothing
114
SocketError.WouldBlock =>
Interop
.Error.EAGAIN,
115
SocketError.SocketError =>
Interop
.Error.ESOCKETERROR,
116
_ =>
Interop
.Error.SUCCESS, // default for unknown mappings
119
internal static
Interop
.Error GetNativeErrorForSocketError(SocketError error)
121
Interop
.Error errno = GetNativeErrorForSocketErrorHelper(error);
122
if (errno ==
Interop
.Error.SUCCESS)
125
errno = (
Interop
.Error)(int)error;
130
internal static bool TryGetNativeErrorForSocketError(SocketError error, out
Interop
.Error errno)
133
return errno !=
Interop
.Error.SUCCESS;
src\libraries\Common\src\System\Net\Sockets\SocketExceptionFactory.Unix.cs (1)
13
if (SocketErrorPal.TryGetNativeErrorForSocketError((SocketError)socketError, out
Interop
.Error interopErr))
System\Net\Sockets\SafeSocketHandle.Unix.cs (23)
200
int fdFlags =
Interop
.Sys.Fcntl.GetFD(handle);
209
Interop
.Error err =
Interop
.Sys.GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Type, (byte*)&type, &optLen);
210
if (err ==
Interop
.Error.SUCCESS)
216
Interop
.Sys.Disconnect(handle);
220
Interop
.Sys.Shutdown(handle, SocketShutdown.Both);
229
Interop
.Error errorCode =
Interop
.Error.SUCCESS;
250
if (errorCode !=
Interop
.Error.EWOULDBLOCK)
257
if (
Interop
.Sys.Fcntl.DangerousSetIsNonBlocking(handle, 0) == 0)
267
var linger = new
Interop
.Sys.LingerOption
273
errorCode =
Interop
.Sys.SetLingerOption(handle, &linger);
281
case
Interop
.Error.SUCCESS:
282
case
Interop
.Error.EINVAL:
283
case
Interop
.Error.ENOPROTOOPT:
284
case
Interop
.Error.ENOTSOCK:
294
private
Interop
.Error CloseHandle(IntPtr handle)
296
Interop
.Error errorCode =
Interop
.Error.SUCCESS;
299
if (
Interop
.Sys.Close(handle) != 0)
301
errorCode =
Interop
.Sys.GetLastError();
302
if (errorCode ==
Interop
.Error.ECONNRESET)
308
errorCode =
Interop
.Error.SUCCESS;
System\Net\Sockets\Socket.Unix.cs (11)
70
Interop
.Error e =
Interop
.Sys.GetSocketType(handle, out addressFamily, out socketType, out protocolType, out isListening);
71
if (e ==
Interop
.Error.ENOTSOCK)
79
if (
Interop
.Sys.FStat(handle, out
Interop
.Sys.FileStatus stat) == -1)
83
isSocket = (stat.Mode &
Interop
.Sys.FileTypes.S_IFSOCK) ==
Interop
.Sys.FileTypes.S_IFSOCK;
93
Interop
.Error e =
Interop
.Sys.GetSocketType(handle, out addressFamily, out socketType, out protocolType, out isListening);
94
Debug.Assert(e ==
Interop
.Error.SUCCESS, e.ToString());
112
int rv =
Interop
.Sys.Fcntl.GetIsNonBlocking(handle, out nonBlocking);
System\Net\Sockets\SocketAsyncContext.Unix.cs (31)
837
if (!context.IsRegistered && !context.TryRegister(out
Interop
.Error error))
921
static void HandleFailedRegistration(SocketAsyncContext context, TOperation operation,
Interop
.Error error)
923
Debug.Assert(error !=
Interop
.Error.SUCCESS);
926
if (error ==
Interop
.Error.EPIPE)
936
if (error ==
Interop
.Error.ENOMEM || error ==
Interop
.Error.ENOSPC)
1286
private bool TryRegister(out
Interop
.Error error)
1319
error =
Interop
.Error.SUCCESS;
1361
if (
Interop
.Sys.Fcntl.SetIsNonBlocking(_socket, 1) != 0)
1363
throw new SocketException((int)SocketPal.GetSocketErrorForErrorCode(
Interop
.Sys.GetLastError()));
2198
public
Interop
.Sys.SocketEvents HandleSyncEventsSpeculatively(
Interop
.Sys.SocketEvents events)
2200
if ((events &
Interop
.Sys.SocketEvents.Error) != 0)
2204
events ^=
Interop
.Sys.SocketEvents.Error;
2205
events |=
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write;
2208
if ((events &
Interop
.Sys.SocketEvents.Read) != 0 &&
2212
events ^=
Interop
.Sys.SocketEvents.Read;
2215
if ((events &
Interop
.Sys.SocketEvents.Write) != 0 &&
2219
events ^=
Interop
.Sys.SocketEvents.Write;
2226
public void HandleEventsInline(
Interop
.Sys.SocketEvents events)
2228
if ((events &
Interop
.Sys.SocketEvents.Error) != 0)
2232
events ^=
Interop
.Sys.SocketEvents.Error;
2233
events |=
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write;
2236
if ((events &
Interop
.Sys.SocketEvents.Read) != 0)
2242
if ((events &
Interop
.Sys.SocketEvents.Write) != 0)
2250
public void HandleEvents(
Interop
.Sys.SocketEvents events)
2252
Debug.Assert((events &
Interop
.Sys.SocketEvents.Error) == 0);
2255
(events &
Interop
.Sys.SocketEvents.Read) != 0 ? _receiveQueue.ProcessSyncEventOrGetAsyncEvent(this) : null;
2257
(events &
Interop
.Sys.SocketEvents.Write) != 0 ? _sendQueue.ProcessSyncEventOrGetAsyncEvent(this) : null;
System\Net\Sockets\SocketAsyncEngine.Unix.cs (26)
80
/// <para>The index is used as the <see cref="
Interop
.Sys.SocketEvent.Data"/> to quickly map events to <see cref="SocketAsyncContext"/>s.</para>
87
private readonly
Interop
.Sys.SocketEvent* _buffer;
115
public static bool TryRegisterSocket(IntPtr socketHandle, SocketAsyncContext context, out SocketAsyncEngine? engine, out
Interop
.Error error)
124
private bool TryRegisterCore(IntPtr socketHandle, SocketAsyncContext context, out
Interop
.Error error)
151
error =
Interop
.Sys.TryChangeSocketEventRegistration(_port, socketHandle,
Interop
.Sys.SocketEvents.None,
152
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write, context.GlobalContextIndex);
153
if (error ==
Interop
.Error.SUCCESS)
184
Interop
.Error err;
187
err =
Interop
.Sys.CreateSocketEventPort(portPtr);
188
if (err !=
Interop
.Error.SUCCESS)
194
fixed (
Interop
.Sys.SocketEvent** bufferPtr = &_buffer)
196
err =
Interop
.Sys.CreateSocketEventBuffer(EventBufferCount, bufferPtr);
197
if (err !=
Interop
.Error.SUCCESS)
225
Interop
.Error err =
Interop
.Sys.WaitForSocketEvents(_port, handler.Buffer, &numEvents);
226
if (err !=
Interop
.Error.SUCCESS)
340
Interop
.Sys.FreeSocketEventBuffer(_buffer);
344
Interop
.Sys.CloseSocketEventPort(_port);
355
public
Interop
.Sys.SocketEvent* Buffer { get; }
369
foreach (var socketEvent in new ReadOnlySpan<
Interop
.Sys.SocketEvent>(Buffer, numEvents))
386
Interop
.Sys.SocketEvents events = context.HandleSyncEventsSpeculatively(socketEvent.Events);
388
if (events !=
Interop
.Sys.SocketEvents.None)
404
public
Interop
.Sys.SocketEvents Events { get; }
406
public SocketIOEvent(SocketAsyncContext context,
Interop
.Sys.SocketEvents events)
System\Net\Sockets\SocketPal.Unix.cs (241)
19
public static readonly int MaximumAddressSize =
Interop
.Sys.GetMaximumAddressSize();
29
Interop
.Sys.PlatformSupportsDualModeIPv4PacketInfo() != 0;
30
public static SocketError GetSocketErrorForErrorCode(
Interop
.Error errorCode)
43
private static unsafe IPPacketInformation GetIPPacketInformation(
Interop
.Sys.MessageHeader* messageHeader, bool isIPv4, bool isIPv6)
50
Interop
.Sys.IPPacketInformation nativePacketInfo = default;
51
if (!
Interop
.Sys.TryGetIPPacketInformation(messageHeader, isIPv4, &nativePacketInfo))
65
Interop
.Error error =
Interop
.Sys.Socket((int)addressFamily, (int)socketType, (int)protocolType, &fd);
66
if (error ==
Interop
.Error.SUCCESS)
78
error =
Interop
.Sys.SetSockOpt(fd, SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, (byte*)&on, sizeof(int));
79
if (error !=
Interop
.Error.SUCCESS)
81
Interop
.Sys.Close(fd);
105
private static unsafe int SysRead(SafeSocketHandle handle, Span<byte> buffer, out
Interop
.Error errno)
113
received =
Interop
.Sys.Read(handle, b, buffer.Length);
114
errno = received != -1 ?
Interop
.Error.SUCCESS :
Interop
.Sys.GetLastError();
120
private static unsafe int SysReceive(SafeSocketHandle socket, SocketFlags flags, Span<byte> buffer, out
Interop
.Error errno)
128
errno =
Interop
.Sys.Receive(
136
if (errno !=
Interop
.Error.SUCCESS)
144
private static unsafe int SysReceive(SafeSocketHandle socket, SocketFlags flags, Span<byte> buffer, Span<byte> socketAddress, out int socketAddressLen, out SocketFlags receivedFlags, out
Interop
.Error errno)
153
var iov = new
Interop
.Sys.IOVector {
160
var messageHeader = new
Interop
.Sys.MessageHeader {
167
errno =
Interop
.Sys.ReceiveMessage(
177
if (errno !=
Interop
.Error.SUCCESS)
185
private static unsafe int SysWrite(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, ref int offset, ref int count, out
Interop
.Error errno)
193
sent =
Interop
.Sys.Write(handle, b + offset, count);
196
errno =
Interop
.Sys.GetLastError();
200
errno =
Interop
.Error.SUCCESS;
214
private static unsafe int SysSend(SafeSocketHandle socket, SocketFlags flags, ReadOnlySpan<byte> buffer, ref int offset, ref int count, out
Interop
.Error errno)
223
errno =
Interop
.Sys.Send(
231
if (errno !=
Interop
.Error.SUCCESS)
241
private static unsafe int SysSend(SafeSocketHandle socket, SocketFlags flags, ReadOnlySpan<byte> buffer, ref int offset, ref int count, ReadOnlySpan<byte> socketAddress, out
Interop
.Error errno)
251
var iov = new
Interop
.Sys.IOVector
257
var messageHeader = new
Interop
.Sys.MessageHeader
266
errno =
Interop
.Sys.SendMessage(
275
if (errno !=
Interop
.Error.SUCCESS)
285
private static unsafe int SysSend(SafeSocketHandle socket, SocketFlags flags, IList<ArraySegment<byte>> buffers, ref int bufferIndex, ref int offset, ReadOnlySpan<byte> socketAddress, out
Interop
.Error errno)
300
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[maxBuffers];
319
fixed (
Interop
.Sys.IOVector* iov = iovecs)
321
var messageHeader = new
Interop
.Sys.MessageHeader {
329
errno =
Interop
.Sys.SendMessage(
347
if (errno !=
Interop
.Error.SUCCESS)
371
private static long SendFile(SafeSocketHandle socket, SafeFileHandle fileHandle, ref long offset, ref long count, out
Interop
.Error errno)
374
errno =
Interop
.Sys.SendFile(socket, fileHandle, offset, count, out bytesSent);
380
private static unsafe int SysReceive(SafeSocketHandle socket, SocketFlags flags, IList<ArraySegment<byte>> buffers, Span<byte> socketAddress, out int socketAddressLen, out SocketFlags receivedFlags, out
Interop
.Error errno)
396
errno =
Interop
.Sys.GetBytesAvailable(socket, &available);
397
if (errno !=
Interop
.Error.SUCCESS)
412
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[maxBuffers];
445
fixed (
Interop
.Sys.IOVector* iov = iovecs)
447
var messageHeader = new
Interop
.Sys.MessageHeader {
454
errno =
Interop
.Sys.ReceiveMessage(
475
if (errno !=
Interop
.Error.SUCCESS)
483
private static unsafe int SysReceiveMessageFrom(SafeSocketHandle socket, SocketFlags flags, Span<byte> buffer, Span<byte> socketAddress, out int socketAddressLen, bool isIPv4, bool isIPv6, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out
Interop
.Error errno)
487
int cmsgBufferLen =
Interop
.Sys.GetControlMessageBufferSize(Convert.ToInt32(isIPv4), Convert.ToInt32(isIPv6));
490
Interop
.Sys.MessageHeader messageHeader;
496
var iov = new
Interop
.Sys.IOVector {
503
messageHeader = new
Interop
.Sys.MessageHeader {
512
errno =
Interop
.Sys.ReceiveMessage(
522
if (errno !=
Interop
.Error.SUCCESS)
541
out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out
Interop
.Error errno)
554
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[buffersCount];
572
fixed (
Interop
.Sys.IOVector* iov = iovecs)
574
int cmsgBufferLen =
Interop
.Sys.GetControlMessageBufferSize(Convert.ToInt32(isIPv4), Convert.ToInt32(isIPv6));
577
var messageHeader = new
Interop
.Sys.MessageHeader
588
errno =
Interop
.Sys.ReceiveMessage(
597
if (errno ==
Interop
.Error.SUCCESS)
629
Interop
.Error errno;
635
errno =
Interop
.Sys.Accept(socket, rawSocketAddress, &sockAddrLen, &fd);
648
if (errno ==
Interop
.Error.SUCCESS)
659
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
682
Interop
.Error err;
688
err =
Interop
.Sys.Connectx(socket, rawSocketAddress, socketAddress.Length, data, data.Length, tfo ? 1 : 0, &sentBytes);
693
err =
Interop
.Sys.Connect(socket, rawSocketAddress, socketAddress.Length);
697
if (err ==
Interop
.Error.SUCCESS)
703
if (err !=
Interop
.Error.EINPROGRESS)
715
Interop
.Error socketError = default;
716
Interop
.Error err;
724
Interop
.PollEvents outEvents;
725
err =
Interop
.Sys.Poll(socket,
Interop
.PollEvents.POLLOUT, timeout: 0, out outEvents);
726
if (err ==
Interop
.Error.SUCCESS)
728
if (outEvents ==
Interop
.PollEvents.POLLNONE)
730
socketError =
Interop
.Error.EINPROGRESS;
734
err =
Interop
.Sys.GetSocketErrorOption(socket, &socketError);
745
if (err !=
Interop
.Error.SUCCESS)
747
Debug.Assert(err ==
Interop
.Error.EBADF, $"Unexpected err: {err}");
752
if (socketError ==
Interop
.Error.SUCCESS)
757
else if (socketError ==
Interop
.Error.EINPROGRESS)
777
Interop
.Error errno;
814
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
836
Interop
.Error errno;
883
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
907
Interop
.Error errno;
928
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
975
Interop
.Error errno;
1001
if (!successfulSend && errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
1041
Interop
.Error errno;
1054
if (errno !=
Interop
.Error.SUCCESS)
1056
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
1085
Interop
.Error err =
Interop
.Sys.GetSockName(handle, buffer, nameLen);
1086
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1092
Interop
.Error err =
Interop
.Sys.GetBytesAvailable(handle, &value);
1095
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1101
Interop
.Error err =
Interop
.Sys.GetAtOutOfBandMark(handle, &value);
1104
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1109
Interop
.Error err;
1113
err =
Interop
.Sys.GetPeerName(handle, rawBuffer, &addrLen);
1117
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1122
Interop
.Error err =
Interop
.Sys.Bind(handle, socketProtocolType, buffer);
1124
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1129
Interop
.Error err =
Interop
.Sys.Listen(handle, backlog);
1130
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1421
private static SocketError GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName,
Interop
.Error err)
1423
if (err ==
Interop
.Error.SUCCESS)
1433
Interop
.Error err;
1440
err =
Interop
.Sys.SetReceiveTimeout(handle, optionValue);
1446
err =
Interop
.Sys.SetSendTimeout(handle, optionValue);
1459
var opt = new
Interop
.Sys.IPv4MulticastOption
1466
err =
Interop
.Sys.SetIPv4MulticastOption(handle,
Interop
.Sys.MulticastOption.MULTICAST_IF, &opt);
1472
err =
Interop
.Sys.SetSockOpt(handle, optionLevel, optionName, (byte*)&optionValue, sizeof(int));
1474
if (err ==
Interop
.Error.SUCCESS)
1506
Interop
.Error err =
Interop
.Sys.SetSockOpt(handle, optionLevel, optionName, pinnedValue, optionValue != null ? optionValue.Length : 0);
1515
Interop
.Error err =
Interop
.Sys.SetRawSockOpt(handle, optionLevel, optionName, optionValuePtr, optionValue.Length);
1517
if (err ==
Interop
.Error.SUCCESS)
1536
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1537
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1538
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1543
var opt = new
Interop
.Sys.IPv4MulticastOption
1551
Interop
.Error err =
Interop
.Sys.SetIPv4MulticastOption(handle, optName, &opt);
1559
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1560
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1561
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1563
var opt = new
Interop
.Sys.IPv6MulticastOption {
1568
Interop
.Error err =
Interop
.Sys.SetIPv6MulticastOption(handle, optName, &opt);
1574
var opt = new
Interop
.Sys.LingerOption {
1579
Interop
.Error err =
Interop
.Sys.SetLingerOption(handle, &opt);
1618
Interop
.Error socketError = default(
Interop
.Error);
1619
Interop
.Error getErrorError =
Interop
.Sys.GetSocketErrorOption(handle, &socketError);
1621
return getErrorError ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(getErrorError);
1626
Interop
.Error err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, (byte*)&value, &optLen);
1640
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1647
Interop
.Error err;
1651
err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, null, &optLen);
1671
err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, pinnedValue, &optLen);
1675
if (err ==
Interop
.Error.SUCCESS)
1691
Interop
.Error err =
Interop
.Sys.GetRawSockOpt(handle, optionLevel, optionName, pinnedValue, &optLen);
1693
if (err ==
Interop
.Error.SUCCESS)
1707
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1708
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1709
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1711
Interop
.Sys.IPv4MulticastOption opt = default;
1712
Interop
.Error err =
Interop
.Sys.GetIPv4MulticastOption(handle, optName, &opt);
1713
if (err !=
Interop
.Error.SUCCESS)
1732
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1733
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1734
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1736
Interop
.Sys.IPv6MulticastOption opt = default;
1737
Interop
.Error err =
Interop
.Sys.GetIPv6MulticastOption(handle, optName, &opt);
1738
if (err !=
Interop
.Error.SUCCESS)
1750
Interop
.Sys.LingerOption opt = default;
1751
Interop
.Error err =
Interop
.Sys.GetLingerOption(handle, &opt);
1752
if (err !=
Interop
.Error.SUCCESS)
1764
Interop
.PollEvents inEvent =
Interop
.PollEvents.POLLNONE;
1767
case SelectMode.SelectRead: inEvent =
Interop
.PollEvents.POLLIN; break;
1768
case SelectMode.SelectWrite: inEvent =
Interop
.PollEvents.POLLOUT; break;
1769
case SelectMode.SelectError: inEvent =
Interop
.PollEvents.POLLPRI; break;
1774
Interop
.PollEvents outEvents;
1775
Interop
.Error err =
Interop
.Sys.Poll(handle, inEvent, milliseconds, out outEvents);
1776
if (err !=
Interop
.Error.SUCCESS)
1784
case SelectMode.SelectRead: status = (outEvents & (
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP)) != 0; break;
1785
case SelectMode.SelectWrite: status = (outEvents &
Interop
.PollEvents.POLLOUT) != 0; break;
1786
case SelectMode.SelectError: status = (outEvents & (
Interop
.PollEvents.POLLERR |
Interop
.PollEvents.POLLPRI)) != 0; break;
1814
Interop
.PollEvent* eventsOnStack = stackalloc
Interop
.PollEvent[count];
1823
var eventsOnHeap = new
Interop
.PollEvent[count];
1824
fixed (
Interop
.PollEvent* eventsOnHeapPtr = &eventsOnHeap[0])
1851
Interop
.Error err =
Interop
.Sys.Select(readFDs, readFDs.Length, writeFDs, writeFDs.Length, errorFDs, errorFDs.Length, microseconds, maxFd, out triggered);
1852
if (err !=
Interop
.Error.SUCCESS)
1936
Interop
.PollEvent* events, int eventsLength,
1947
AddToPollArray(events, eventsLength, checkRead, ref offset,
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP, ref refsAdded);
1948
AddToPollArray(events, eventsLength, checkWrite, ref offset,
Interop
.PollEvents.POLLOUT, ref refsAdded);
1949
AddToPollArray(events, eventsLength, checkError, ref offset,
Interop
.PollEvents.POLLPRI, ref refsAdded);
1956
Interop
.Error err =
Interop
.Sys.Poll(events, (uint)eventsLength, milliseconds, &triggered);
1957
if (err !=
Interop
.Error.SUCCESS)
1975
FilterPollList(checkRead, events, checkReadInitialCount - 1,
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP, ref refsAdded);
1976
FilterPollList(checkWrite, events, checkWriteInitialCount + checkReadInitialCount - 1,
Interop
.PollEvents.POLLOUT, ref refsAdded);
1977
FilterPollList(checkError, events, checkErrorInitialCount + checkWriteInitialCount + checkReadInitialCount - 1,
Interop
.PollEvents.POLLERR |
Interop
.PollEvents.POLLPRI, ref refsAdded);
1993
private static unsafe void AddToPollArray(
Interop
.PollEvent* arr, int arrLength, IList? socketList, ref int arrOffset,
Interop
.PollEvents events, ref int refsAdded)
2013
arr[arrOffset++] = new
Interop
.PollEvent { Events = events, FileDescriptor = fd };
2018
private static unsafe void FilterPollList(IList? socketList,
Interop
.PollEvent* arr, int arrEndOffset,
Interop
.PollEvents desiredEvents, ref int refsAdded)
2051
Interop
.Error err =
Interop
.Sys.Shutdown(handle, how);
2052
if (err ==
Interop
.Error.SUCCESS)
2061
if (err ==
Interop
.Error.ENOTCONN && (isConnected || isDisconnected))
2177
Interop
.Error err =
Interop
.Sys.Poll(handle,
Interop
.PollEvents.POLLOUT, timeout: 0, out
Interop
.PollEvents outEvents);
2178
if (err !=
Interop
.Error.SUCCESS)
2184
if ((outEvents &
Interop
.PollEvents.POLLOUT) == 0)
System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs (1)
24
Interop
.Sys.GetDomainSocketSizes(pathOffset, pathLength, addressSize);