459 references to Interop
System.Net.Sockets (459)
src\libraries\Common\src\Interop\Unix\Interop.Errors.cs (6)
123
_error =
Interop
.Sys.ConvertErrorPlatformToPal(errno);
140
get { return _rawErrno == -1 ? (_rawErrno =
Interop
.Sys.ConvertErrorPalToPlatform(_error)) : _rawErrno; }
145
return
Interop
.Sys.StrError(RawErrno);
219
public static
Interop
.ErrorInfo Info(this
Interop
.Error error)
221
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)
34
private static readonly Dictionary<
Interop
.Error, SocketError> s_nativeErrorToSocketError = new Dictionary<
Interop
.Error, SocketError>(NativeErrorToSocketErrorCount)
36
{
Interop
.Error.EACCES, SocketError.AccessDenied },
37
{
Interop
.Error.EADDRINUSE, SocketError.AddressAlreadyInUse },
38
{
Interop
.Error.EADDRNOTAVAIL, SocketError.AddressNotAvailable },
39
{
Interop
.Error.EAFNOSUPPORT, SocketError.AddressFamilyNotSupported },
40
{
Interop
.Error.EAGAIN, SocketError.WouldBlock },
41
{
Interop
.Error.EALREADY, SocketError.AlreadyInProgress },
42
{
Interop
.Error.EBADF, SocketError.OperationAborted },
43
{
Interop
.Error.ECANCELED, SocketError.OperationAborted },
44
{
Interop
.Error.ECONNABORTED, SocketError.ConnectionAborted },
45
{
Interop
.Error.ECONNREFUSED, SocketError.ConnectionRefused },
46
{
Interop
.Error.ECONNRESET, SocketError.ConnectionReset },
47
{
Interop
.Error.EDESTADDRREQ, SocketError.DestinationAddressRequired },
48
{
Interop
.Error.EFAULT, SocketError.Fault },
49
{
Interop
.Error.EHOSTDOWN, SocketError.HostDown },
50
{
Interop
.Error.ENXIO, SocketError.HostNotFound }, // not perfect, but closest match available
51
{
Interop
.Error.EHOSTUNREACH, SocketError.HostUnreachable },
52
{
Interop
.Error.EINPROGRESS, SocketError.InProgress },
53
{
Interop
.Error.EINTR, SocketError.Interrupted },
54
{
Interop
.Error.EINVAL, SocketError.InvalidArgument },
55
{
Interop
.Error.EISCONN, SocketError.IsConnected },
56
{
Interop
.Error.EMFILE, SocketError.TooManyOpenSockets },
57
{
Interop
.Error.EMSGSIZE, SocketError.MessageSize },
58
{
Interop
.Error.ENETDOWN, SocketError.NetworkDown },
59
{
Interop
.Error.ENETRESET, SocketError.NetworkReset },
60
{
Interop
.Error.ENETUNREACH, SocketError.NetworkUnreachable },
61
{
Interop
.Error.ENFILE, SocketError.TooManyOpenSockets },
62
{
Interop
.Error.ENOBUFS, SocketError.NoBufferSpaceAvailable },
63
{
Interop
.Error.ENODATA, SocketError.NoData },
64
{
Interop
.Error.ENOENT, SocketError.AddressNotAvailable },
65
{
Interop
.Error.ENOPROTOOPT, SocketError.ProtocolOption },
66
{
Interop
.Error.ENOTCONN, SocketError.NotConnected },
67
{
Interop
.Error.ENOTSOCK, SocketError.NotSocket },
68
{
Interop
.Error.ENOTSUP, SocketError.OperationNotSupported },
69
{
Interop
.Error.EPERM, SocketError.AccessDenied },
70
{
Interop
.Error.EPIPE, SocketError.Shutdown },
71
{
Interop
.Error.EPFNOSUPPORT, SocketError.ProtocolFamilyNotSupported },
72
{
Interop
.Error.EPROTONOSUPPORT, SocketError.ProtocolNotSupported },
73
{
Interop
.Error.EPROTOTYPE, SocketError.ProtocolType },
74
{
Interop
.Error.ESOCKTNOSUPPORT, SocketError.SocketNotSupported },
75
{
Interop
.Error.ESHUTDOWN, SocketError.Disconnecting },
76
{
Interop
.Error.SUCCESS, SocketError.Success },
77
{
Interop
.Error.ETIMEDOUT, SocketError.TimedOut },
80
private static readonly Dictionary<SocketError,
Interop
.Error> s_socketErrorToNativeError = new Dictionary<SocketError,
Interop
.Error>(SocketErrorToNativeErrorCount)
88
{ SocketError.AccessDenied,
Interop
.Error.EACCES}, // could also have been EPERM
89
{ SocketError.AddressAlreadyInUse,
Interop
.Error.EADDRINUSE },
90
{ SocketError.AddressNotAvailable,
Interop
.Error.EADDRNOTAVAIL },
91
{ SocketError.AddressFamilyNotSupported,
Interop
.Error.EAFNOSUPPORT },
92
{ SocketError.AlreadyInProgress,
Interop
.Error.EALREADY },
93
{ SocketError.ConnectionAborted,
Interop
.Error.ECONNABORTED },
94
{ SocketError.ConnectionRefused,
Interop
.Error.ECONNREFUSED },
95
{ SocketError.ConnectionReset,
Interop
.Error.ECONNRESET },
96
{ SocketError.DestinationAddressRequired,
Interop
.Error.EDESTADDRREQ },
97
{ SocketError.Disconnecting,
Interop
.Error.ESHUTDOWN },
98
{ SocketError.Fault,
Interop
.Error.EFAULT },
99
{ SocketError.HostDown,
Interop
.Error.EHOSTDOWN },
100
{ SocketError.HostNotFound,
Interop
.Error.EHOSTNOTFOUND },
101
{ SocketError.HostUnreachable,
Interop
.Error.EHOSTUNREACH },
102
{ SocketError.InProgress,
Interop
.Error.EINPROGRESS },
103
{ SocketError.Interrupted,
Interop
.Error.EINTR },
104
{ SocketError.InvalidArgument,
Interop
.Error.EINVAL },
105
{ SocketError.IOPending,
Interop
.Error.EINPROGRESS },
106
{ SocketError.IsConnected,
Interop
.Error.EISCONN },
107
{ SocketError.MessageSize,
Interop
.Error.EMSGSIZE },
108
{ SocketError.NetworkDown,
Interop
.Error.ENETDOWN },
109
{ SocketError.NetworkReset,
Interop
.Error.ENETRESET },
110
{ SocketError.NetworkUnreachable,
Interop
.Error.ENETUNREACH },
111
{ SocketError.NoBufferSpaceAvailable,
Interop
.Error.ENOBUFS },
112
{ SocketError.NoData,
Interop
.Error.ENODATA },
113
{ SocketError.NotConnected,
Interop
.Error.ENOTCONN },
114
{ SocketError.NotSocket,
Interop
.Error.ENOTSOCK },
115
{ SocketError.OperationAborted,
Interop
.Error.ECANCELED },
116
{ SocketError.OperationNotSupported,
Interop
.Error.ENOTSUP },
117
{ SocketError.ProtocolFamilyNotSupported,
Interop
.Error.EPFNOSUPPORT },
118
{ SocketError.ProtocolNotSupported,
Interop
.Error.EPROTONOSUPPORT },
119
{ SocketError.ProtocolOption,
Interop
.Error.ENOPROTOOPT },
120
{ SocketError.ProtocolType,
Interop
.Error.EPROTOTYPE },
121
{ SocketError.Shutdown,
Interop
.Error.EPIPE },
122
{ SocketError.SocketNotSupported,
Interop
.Error.ESOCKTNOSUPPORT },
123
{ SocketError.Success,
Interop
.Error.SUCCESS },
124
{ SocketError.TimedOut,
Interop
.Error.ETIMEDOUT },
125
{ SocketError.TooManyOpenSockets,
Interop
.Error.ENFILE }, // could also have been EMFILE
126
{ SocketError.TryAgain,
Interop
.Error.EAGAIN }, // not a perfect mapping, but better than nothing
127
{ SocketError.WouldBlock,
Interop
.Error.EAGAIN },
128
{ SocketError.SocketError,
Interop
.Error.ESOCKETERROR },
131
internal static SocketError GetSocketErrorForNativeError(
Interop
.Error errno)
139
internal static
Interop
.Error GetNativeErrorForSocketError(SocketError error)
141
Interop
.Error errno;
145
errno = (
Interop
.Error)(int)error;
150
internal static bool TryGetNativeErrorForSocketError(SocketError error, out
Interop
.Error errno)
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)
199
int fdFlags =
Interop
.Sys.Fcntl.GetFD(handle);
208
Interop
.Error err =
Interop
.Sys.GetSockOpt(handle, SocketOptionLevel.Socket, SocketOptionName.Type, (byte*)&type, &optLen);
209
if (err ==
Interop
.Error.SUCCESS)
215
Interop
.Sys.Disconnect(handle);
219
Interop
.Sys.Shutdown(handle, SocketShutdown.Both);
228
Interop
.Error errorCode =
Interop
.Error.SUCCESS;
244
if (errorCode !=
Interop
.Error.EWOULDBLOCK)
251
if (
Interop
.Sys.Fcntl.DangerousSetIsNonBlocking(handle, 0) == 0)
261
var linger = new
Interop
.Sys.LingerOption
267
errorCode =
Interop
.Sys.SetLingerOption(handle, &linger);
275
case
Interop
.Error.SUCCESS:
276
case
Interop
.Error.EINVAL:
277
case
Interop
.Error.ENOPROTOOPT:
278
case
Interop
.Error.ENOTSOCK:
288
private
Interop
.Error CloseHandle(IntPtr handle)
290
Interop
.Error errorCode =
Interop
.Error.SUCCESS;
293
if (
Interop
.Sys.Close(handle) != 0)
295
errorCode =
Interop
.Sys.GetLastError();
296
if (errorCode ==
Interop
.Error.ECONNRESET)
302
errorCode =
Interop
.Error.SUCCESS;
System\Net\Sockets\Socket.Unix.cs (8)
64
if (
Interop
.Sys.FStat(handle, out
Interop
.Sys.FileStatus stat) == -1)
68
isSocket = (stat.Mode &
Interop
.Sys.FileTypes.S_IFSOCK) ==
Interop
.Sys.FileTypes.S_IFSOCK;
78
Interop
.Error e =
Interop
.Sys.GetSocketType(handle, out addressFamily, out socketType, out protocolType, out isListening);
79
Debug.Assert(e ==
Interop
.Error.SUCCESS, e.ToString());
97
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)
1284
private bool TryRegister(out
Interop
.Error error)
1317
error =
Interop
.Error.SUCCESS;
1351
if (
Interop
.Sys.Fcntl.SetIsNonBlocking(_socket, 1) != 0)
1353
throw new SocketException((int)SocketPal.GetSocketErrorForErrorCode(
Interop
.Sys.GetLastError()));
2167
public
Interop
.Sys.SocketEvents HandleSyncEventsSpeculatively(
Interop
.Sys.SocketEvents events)
2169
if ((events &
Interop
.Sys.SocketEvents.Error) != 0)
2173
events ^=
Interop
.Sys.SocketEvents.Error;
2174
events |=
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write;
2177
if ((events &
Interop
.Sys.SocketEvents.Read) != 0 &&
2181
events ^=
Interop
.Sys.SocketEvents.Read;
2184
if ((events &
Interop
.Sys.SocketEvents.Write) != 0 &&
2188
events ^=
Interop
.Sys.SocketEvents.Write;
2195
public void HandleEventsInline(
Interop
.Sys.SocketEvents events)
2197
if ((events &
Interop
.Sys.SocketEvents.Error) != 0)
2201
events ^=
Interop
.Sys.SocketEvents.Error;
2202
events |=
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write;
2205
if ((events &
Interop
.Sys.SocketEvents.Read) != 0)
2211
if ((events &
Interop
.Sys.SocketEvents.Write) != 0)
2219
public unsafe void HandleEvents(
Interop
.Sys.SocketEvents events)
2221
Debug.Assert((events &
Interop
.Sys.SocketEvents.Error) == 0);
2224
(events &
Interop
.Sys.SocketEvents.Read) != 0 ? _receiveQueue.ProcessSyncEventOrGetAsyncEvent(this) : null;
2226
(events &
Interop
.Sys.SocketEvents.Write) != 0 ? _sendQueue.ProcessSyncEventOrGetAsyncEvent(this) : null;
System\Net\Sockets\SocketAsyncEngine.Unix.cs (25)
78
private readonly
Interop
.Sys.SocketEvent* _buffer;
111
public static bool TryRegisterSocket(IntPtr socketHandle, SocketAsyncContext context, out SocketAsyncEngine? engine, out
Interop
.Error error)
120
private bool TryRegisterCore(IntPtr socketHandle, SocketAsyncContext context, out
Interop
.Error error)
130
error =
Interop
.Sys.TryChangeSocketEventRegistration(_port, socketHandle,
Interop
.Sys.SocketEvents.None,
131
Interop
.Sys.SocketEvents.Read |
Interop
.Sys.SocketEvents.Write, socketHandle);
132
if (error ==
Interop
.Error.SUCCESS)
154
Interop
.Error err;
157
err =
Interop
.Sys.CreateSocketEventPort(portPtr);
158
if (err !=
Interop
.Error.SUCCESS)
164
fixed (
Interop
.Sys.SocketEvent** bufferPtr = &_buffer)
166
err =
Interop
.Sys.CreateSocketEventBuffer(EventBufferCount, bufferPtr);
167
if (err !=
Interop
.Error.SUCCESS)
195
Interop
.Error err =
Interop
.Sys.WaitForSocketEvents(_port, handler.Buffer, &numEvents);
196
if (err !=
Interop
.Error.SUCCESS)
310
Interop
.Sys.FreeSocketEventBuffer(_buffer);
314
Interop
.Sys.CloseSocketEventPort(_port);
325
public
Interop
.Sys.SocketEvent* Buffer { get; }
341
foreach (var socketEvent in new ReadOnlySpan<
Interop
.Sys.SocketEvent>(Buffer, numEvents))
353
Interop
.Sys.SocketEvents events = context.HandleSyncEventsSpeculatively(socketEvent.Events);
355
if (events !=
Interop
.Sys.SocketEvents.None)
383
public
Interop
.Sys.SocketEvents Events { get; }
385
public SocketIOEvent(SocketAsyncContext context,
Interop
.Sys.SocketEvents events)
System\Net\Sockets\SocketPal.Unix.cs (238)
19
public static readonly int MaximumAddressSize =
Interop
.Sys.GetMaximumAddressSize();
27
Interop
.Sys.PlatformSupportsDualModeIPv4PacketInfo() != 0;
28
public static SocketError GetSocketErrorForErrorCode(
Interop
.Error errorCode)
41
private static unsafe IPPacketInformation GetIPPacketInformation(
Interop
.Sys.MessageHeader* messageHeader, bool isIPv4, bool isIPv6)
48
Interop
.Sys.IPPacketInformation nativePacketInfo = default;
49
if (!
Interop
.Sys.TryGetIPPacketInformation(messageHeader, isIPv4, &nativePacketInfo))
63
Interop
.Error error =
Interop
.Sys.Socket((int)addressFamily, (int)socketType, (int)protocolType, &fd);
64
if (error ==
Interop
.Error.SUCCESS)
75
error =
Interop
.Sys.SetSockOpt(fd, SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, (byte*)&on, sizeof(int));
76
if (error !=
Interop
.Error.SUCCESS)
78
Interop
.Sys.Close(fd);
102
private static unsafe int SysRead(SafeSocketHandle handle, Span<byte> buffer, out
Interop
.Error errno)
110
received =
Interop
.Sys.Read(handle, b, buffer.Length);
111
errno = received != -1 ?
Interop
.Error.SUCCESS :
Interop
.Sys.GetLastError();
117
private static unsafe int SysReceive(SafeSocketHandle socket, SocketFlags flags, Span<byte> buffer, out
Interop
.Error errno)
125
errno =
Interop
.Sys.Receive(
133
if (errno !=
Interop
.Error.SUCCESS)
141
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)
150
var iov = new
Interop
.Sys.IOVector {
157
var messageHeader = new
Interop
.Sys.MessageHeader {
164
errno =
Interop
.Sys.ReceiveMessage(
174
if (errno !=
Interop
.Error.SUCCESS)
182
private static unsafe int SysWrite(SafeSocketHandle handle, ReadOnlySpan<byte> buffer, ref int offset, ref int count, out
Interop
.Error errno)
190
sent =
Interop
.Sys.Write(handle, b + offset, count);
193
errno =
Interop
.Sys.GetLastError();
197
errno =
Interop
.Error.SUCCESS;
211
private static unsafe int SysSend(SafeSocketHandle socket, SocketFlags flags, ReadOnlySpan<byte> buffer, ref int offset, ref int count, out
Interop
.Error errno)
220
errno =
Interop
.Sys.Send(
228
if (errno !=
Interop
.Error.SUCCESS)
238
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)
248
var iov = new
Interop
.Sys.IOVector
254
var messageHeader = new
Interop
.Sys.MessageHeader
263
errno =
Interop
.Sys.SendMessage(
272
if (errno !=
Interop
.Error.SUCCESS)
282
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)
292
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[maxBuffers];
311
fixed (
Interop
.Sys.IOVector* iov = iovecs)
313
var messageHeader = new
Interop
.Sys.MessageHeader {
321
errno =
Interop
.Sys.SendMessage(
339
if (errno !=
Interop
.Error.SUCCESS)
363
private static unsafe long SendFile(SafeSocketHandle socket, SafeFileHandle fileHandle, ref long offset, ref long count, out
Interop
.Error errno)
366
errno =
Interop
.Sys.SendFile(socket, fileHandle, offset, count, out bytesSent);
372
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)
383
errno =
Interop
.Sys.GetBytesAvailable(socket, &available);
384
if (errno !=
Interop
.Error.SUCCESS)
399
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[maxBuffers];
432
fixed (
Interop
.Sys.IOVector* iov = iovecs)
434
var messageHeader = new
Interop
.Sys.MessageHeader {
441
errno =
Interop
.Sys.ReceiveMessage(
462
if (errno !=
Interop
.Error.SUCCESS)
470
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)
474
int cmsgBufferLen =
Interop
.Sys.GetControlMessageBufferSize(Convert.ToInt32(isIPv4), Convert.ToInt32(isIPv6));
477
Interop
.Sys.MessageHeader messageHeader;
483
var iov = new
Interop
.Sys.IOVector {
490
messageHeader = new
Interop
.Sys.MessageHeader {
499
errno =
Interop
.Sys.ReceiveMessage(
509
if (errno !=
Interop
.Error.SUCCESS)
528
out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out
Interop
.Error errno)
535
Span<
Interop
.Sys.IOVector> iovecs = allocOnStack ? stackalloc
Interop
.Sys.IOVector[IovStackThreshold] : new
Interop
.Sys.IOVector[buffersCount];
553
fixed (
Interop
.Sys.IOVector* iov = iovecs)
555
int cmsgBufferLen =
Interop
.Sys.GetControlMessageBufferSize(Convert.ToInt32(isIPv4), Convert.ToInt32(isIPv6));
558
var messageHeader = new
Interop
.Sys.MessageHeader
569
errno =
Interop
.Sys.ReceiveMessage(
578
if (errno ==
Interop
.Error.SUCCESS)
610
Interop
.Error errno;
616
errno =
Interop
.Sys.Accept(socket, rawSocketAddress, &sockAddrLen, &fd);
629
if (errno ==
Interop
.Error.SUCCESS)
640
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
663
Interop
.Error err;
669
err =
Interop
.Sys.Connectx(socket, rawSocketAddress, socketAddress.Length, data, data.Length, tfo ? 1 : 0, &sentBytes);
674
err =
Interop
.Sys.Connect(socket, rawSocketAddress, socketAddress.Length);
678
if (err ==
Interop
.Error.SUCCESS)
684
if (err !=
Interop
.Error.EINPROGRESS)
696
Interop
.Error socketError = default;
697
Interop
.Error err;
705
Interop
.PollEvents outEvents;
706
err =
Interop
.Sys.Poll(socket,
Interop
.PollEvents.POLLOUT, timeout: 0, out outEvents);
707
if (err ==
Interop
.Error.SUCCESS)
709
if (outEvents ==
Interop
.PollEvents.POLLNONE)
711
socketError =
Interop
.Error.EINPROGRESS;
715
err =
Interop
.Sys.GetSocketErrorOption(socket, &socketError);
726
if (err !=
Interop
.Error.SUCCESS)
728
Debug.Assert(err ==
Interop
.Error.EBADF, $"Unexpected err: {err}");
733
if (socketError ==
Interop
.Error.SUCCESS)
738
else if (socketError ==
Interop
.Error.EINPROGRESS)
758
Interop
.Error errno;
795
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
817
Interop
.Error errno;
864
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
888
Interop
.Error errno;
909
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
956
Interop
.Error errno;
982
if (!successfulSend && errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
1022
Interop
.Error errno;
1035
if (errno !=
Interop
.Error.SUCCESS)
1037
if (errno !=
Interop
.Error.EAGAIN && errno !=
Interop
.Error.EWOULDBLOCK)
1064
Interop
.Error err =
Interop
.Sys.GetSockName(handle, buffer, nameLen);
1065
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1071
Interop
.Error err =
Interop
.Sys.GetBytesAvailable(handle, &value);
1074
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1080
Interop
.Error err =
Interop
.Sys.GetAtOutOfBandMark(handle, &value);
1083
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1088
Interop
.Error err;
1092
err =
Interop
.Sys.GetPeerName(handle, rawBuffer, &addrLen);
1096
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1101
Interop
.Error err =
Interop
.Sys.Bind(handle, socketProtocolType, buffer);
1103
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1108
Interop
.Error err =
Interop
.Sys.Listen(handle, backlog);
1109
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1400
private static SocketError GetErrorAndTrackSetting(SafeSocketHandle handle, SocketOptionLevel optionLevel, SocketOptionName optionName,
Interop
.Error err)
1402
if (err ==
Interop
.Error.SUCCESS)
1412
Interop
.Error err;
1419
err =
Interop
.Sys.SetReceiveTimeout(handle, optionValue);
1425
err =
Interop
.Sys.SetSendTimeout(handle, optionValue);
1438
var opt = new
Interop
.Sys.IPv4MulticastOption
1445
err =
Interop
.Sys.SetIPv4MulticastOption(handle,
Interop
.Sys.MulticastOption.MULTICAST_IF, &opt);
1451
err =
Interop
.Sys.SetSockOpt(handle, optionLevel, optionName, (byte*)&optionValue, sizeof(int));
1453
if (err ==
Interop
.Error.SUCCESS)
1485
Interop
.Error err =
Interop
.Sys.SetSockOpt(handle, optionLevel, optionName, pinnedValue, optionValue != null ? optionValue.Length : 0);
1494
Interop
.Error err =
Interop
.Sys.SetRawSockOpt(handle, optionLevel, optionName, optionValuePtr, optionValue.Length);
1496
if (err ==
Interop
.Error.SUCCESS)
1515
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1516
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1517
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1522
var opt = new
Interop
.Sys.IPv4MulticastOption
1530
Interop
.Error err =
Interop
.Sys.SetIPv4MulticastOption(handle, optName, &opt);
1538
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1539
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1540
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1542
var opt = new
Interop
.Sys.IPv6MulticastOption {
1547
Interop
.Error err =
Interop
.Sys.SetIPv6MulticastOption(handle, optName, &opt);
1553
var opt = new
Interop
.Sys.LingerOption {
1558
Interop
.Error err =
Interop
.Sys.SetLingerOption(handle, &opt);
1597
Interop
.Error socketError = default(
Interop
.Error);
1598
Interop
.Error getErrorError =
Interop
.Sys.GetSocketErrorOption(handle, &socketError);
1600
return getErrorError ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(getErrorError);
1605
Interop
.Error err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, (byte*)&value, &optLen);
1619
return err ==
Interop
.Error.SUCCESS ? SocketError.Success : GetSocketErrorForErrorCode(err);
1626
Interop
.Error err;
1630
err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, null, &optLen);
1650
err =
Interop
.Sys.GetSockOpt(handle, optionLevel, optionName, pinnedValue, &optLen);
1654
if (err ==
Interop
.Error.SUCCESS)
1670
Interop
.Error err =
Interop
.Sys.GetRawSockOpt(handle, optionLevel, optionName, pinnedValue, &optLen);
1672
if (err ==
Interop
.Error.SUCCESS)
1686
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1687
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1688
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1690
Interop
.Sys.IPv4MulticastOption opt = default;
1691
Interop
.Error err =
Interop
.Sys.GetIPv4MulticastOption(handle, optName, &opt);
1692
if (err !=
Interop
.Error.SUCCESS)
1711
Interop
.Sys.MulticastOption optName = optionName == SocketOptionName.AddMembership ?
1712
Interop
.Sys.MulticastOption.MULTICAST_ADD :
1713
Interop
.Sys.MulticastOption.MULTICAST_DROP;
1715
Interop
.Sys.IPv6MulticastOption opt = default;
1716
Interop
.Error err =
Interop
.Sys.GetIPv6MulticastOption(handle, optName, &opt);
1717
if (err !=
Interop
.Error.SUCCESS)
1729
Interop
.Sys.LingerOption opt = default;
1730
Interop
.Error err =
Interop
.Sys.GetLingerOption(handle, &opt);
1731
if (err !=
Interop
.Error.SUCCESS)
1743
Interop
.PollEvents inEvent =
Interop
.PollEvents.POLLNONE;
1746
case SelectMode.SelectRead: inEvent =
Interop
.PollEvents.POLLIN; break;
1747
case SelectMode.SelectWrite: inEvent =
Interop
.PollEvents.POLLOUT; break;
1748
case SelectMode.SelectError: inEvent =
Interop
.PollEvents.POLLPRI; break;
1753
Interop
.PollEvents outEvents;
1754
Interop
.Error err =
Interop
.Sys.Poll(handle, inEvent, milliseconds, out outEvents);
1755
if (err !=
Interop
.Error.SUCCESS)
1763
case SelectMode.SelectRead: status = (outEvents & (
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP)) != 0; break;
1764
case SelectMode.SelectWrite: status = (outEvents &
Interop
.PollEvents.POLLOUT) != 0; break;
1765
case SelectMode.SelectError: status = (outEvents & (
Interop
.PollEvents.POLLERR |
Interop
.PollEvents.POLLPRI)) != 0; break;
1788
Interop
.PollEvent* eventsOnStack = stackalloc
Interop
.PollEvent[count];
1797
var eventsOnHeap = new
Interop
.PollEvent[count];
1798
fixed (
Interop
.PollEvent* eventsOnHeapPtr = &eventsOnHeap[0])
1813
Interop
.PollEvent* events, int eventsLength,
1824
AddToPollArray(events, eventsLength, checkRead, ref offset,
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP, ref refsAdded);
1825
AddToPollArray(events, eventsLength, checkWrite, ref offset,
Interop
.PollEvents.POLLOUT, ref refsAdded);
1826
AddToPollArray(events, eventsLength, checkError, ref offset,
Interop
.PollEvents.POLLPRI, ref refsAdded);
1833
Interop
.Error err =
Interop
.Sys.Poll(events, (uint)eventsLength, milliseconds, &triggered);
1834
if (err !=
Interop
.Error.SUCCESS)
1852
FilterPollList(checkRead, events, checkReadInitialCount - 1,
Interop
.PollEvents.POLLIN |
Interop
.PollEvents.POLLHUP, ref refsAdded);
1853
FilterPollList(checkWrite, events, checkWriteInitialCount + checkReadInitialCount - 1,
Interop
.PollEvents.POLLOUT, ref refsAdded);
1854
FilterPollList(checkError, events, checkErrorInitialCount + checkWriteInitialCount + checkReadInitialCount - 1,
Interop
.PollEvents.POLLERR |
Interop
.PollEvents.POLLPRI, ref refsAdded);
1870
private static unsafe void AddToPollArray(
Interop
.PollEvent* arr, int arrLength, IList? socketList, ref int arrOffset,
Interop
.PollEvents events, ref int refsAdded)
1890
arr[arrOffset++] = new
Interop
.PollEvent { Events = events, FileDescriptor = fd };
1895
private static unsafe void FilterPollList(IList? socketList,
Interop
.PollEvent* arr, int arrEndOffset,
Interop
.PollEvents desiredEvents, ref int refsAdded)
1928
Interop
.Error err =
Interop
.Sys.Shutdown(handle, how);
1929
if (err ==
Interop
.Error.SUCCESS)
1938
if (err ==
Interop
.Error.ENOTCONN && (isConnected || isDisconnected))
2054
Interop
.Error err =
Interop
.Sys.Poll(handle,
Interop
.PollEvents.POLLOUT, timeout: 0, out
Interop
.PollEvents outEvents);
2055
if (err !=
Interop
.Error.SUCCESS)
2061
if ((outEvents &
Interop
.PollEvents.POLLOUT) == 0)
System\Net\Sockets\UnixDomainSocketEndPoint.Unix.cs (1)
24
Interop
.Sys.GetDomainSocketSizes(pathOffset, pathLength, addressSize);