83 instantiations of Socket
ClientSample (1)
dotnet-svcutil-lib (2)
IIS.Common.TestLib (1)
IIS.FunctionalTests (1)
IIS.LongTests (1)
IIS.NewHandler.FunctionalTests (1)
IIS.NewShim.FunctionalTests (1)
IISExpress.FunctionalTests (2)
InMemory.FunctionalTests (3)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (8)
Microsoft.AspNetCore.Server.IntegrationTesting (3)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (3)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (1)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (5)
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
Microsoft.Extensions.Hosting.Systemd (1)
Sockets.BindTests (10)
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (7)
538using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
573using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
940using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
948using (var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp))
1195using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
1211using (var serverSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
1250using (var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
Sockets.FunctionalTests (10)
System.IO.Pipes (3)
System.Net.Http (1)
System.Net.HttpListener (1)
System.Net.NetworkInformation (1)
System.Net.Ping (2)
System.Net.Requests (4)
System.Net.Sockets (14)
System.ServiceModel.NetTcp (1)
System.ServiceModel.UnixDomainSocket (1)
411 references to Socket
ClientSample (5)
dotnet-svcutil-lib (4)
IIS.Common.TestLib (6)
IIS.FunctionalTests (1)
IIS.LongTests (1)
IIS.NewHandler.FunctionalTests (1)
IIS.NewShim.FunctionalTests (1)
IISExpress.FunctionalTests (2)
InMemory.FunctionalTests (10)
Microsoft.AspNetCore.Connections.Abstractions (1)
Microsoft.AspNetCore.InternalTesting (5)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (8)
Microsoft.AspNetCore.Server.IntegrationTesting (3)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (10)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic.Tests (2)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (22)
Microsoft.AspNetCore.StaticFiles.FunctionalTests (3)
Microsoft.Extensions.Hosting.Systemd (1)
netstandard (1)
Sockets.BindTests (27)
src\Servers\Kestrel\test\BindTests\AddressRegistrationTests.cs (8)
538using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
573using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
940using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
948using (var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp))
1195using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
1211using (var serverSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
1229if (Socket.ConnectAsync(SocketType.Stream, ProtocolType.Tcp, socketArgs))
1250using (var socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
Sockets.FunctionalTests (24)
System (1)
System.IO.Pipes (16)
System.Net (1)
System.Net.Http (2)
System.Net.HttpListener (5)
System.Net.Mail (1)
System.Net.NetworkInformation (10)
System.Net.Ping (5)
System.Net.Quic (1)
System.Net.Requests (14)
System.Net.Sockets (206)
System\Net\Sockets\Socket.cs (63)
69private int _closeTimeout = Socket.DefaultCloseTimeout;
103/// <summary>Initializes a new instance of the <see cref="Socket"/> class for the specified socket handle.</summary>
104/// <param name="handle">The socket handle for the socket that the <see cref="Socket"/> object will encapsulate.</param>
109/// This method populates the <see cref="Socket"/> instance with data gathered from the supplied <see cref="SafeSocketHandle"/>.
111/// properties and configuration, which means some of the public APIs on the resulting <see cref="Socket"/> instance may
112/// differ based on operating system, such as <see cref="Socket.ProtocolType"/> and <see cref="Socket.Blocking"/>.
960/// Places a <see cref="Socket"/> in a listening state.
968/// Places a <see cref="Socket"/> in a listening state.
988public Socket Accept()
1049Socket socket = CreateAcceptSocket(acceptedSocketHandle, _rightEndPoint.Create(socketAddress));
1211/// Sends the file <paramref name="fileName"/> and buffers of data to a connected <see cref="Socket"/> object
1226/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception>
1227/// <exception cref="NotSupportedException">The <see cref="Socket"/> object is not connected to a remote host.</exception>
1228/// <exception cref="InvalidOperationException">The <see cref="Socket"/> object is not in blocking mode and cannot accept this synchronous call.</exception>
1237/// Sends the file <paramref name="fileName"/> and buffers of data to a connected <see cref="Socket"/> object
1252/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception>
1253/// <exception cref="NotSupportedException">The <see cref="Socket"/> object is not connected to a remote host.</exception>
1254/// <exception cref="InvalidOperationException">The <see cref="Socket"/> object is not in blocking mode and cannot accept this synchronous call.</exception>
1333/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
1348/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
1389/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
1631/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception>
1634/// <see cref="Socket.ReceiveMessageFrom(Span{byte}, ref SocketFlags, ref EndPoint, out IPPacketInformation)"/>
1637/// <para>The <see cref="Socket"/> object is not in blocking mode and cannot accept this synchronous call.</para>
1801/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
1816/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
1897/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
2043/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
2046/// In general, the SetSocketOption method should be used whenever setting a <see cref="Socket"/> option.
2163/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
2166/// In general, the GetSocketOption method should be used whenever getting a <see cref="Socket"/> option.
2209/// <summary>Determines the status of the <see cref="Socket"/>.</summary>
2213/// The status of the <see cref="Socket"/> based on the polling mode value passed in the <paramref name="mode"/> parameter.
2223/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
2241/// <summary>Determines the status of the <see cref="Socket"/>.</summary>
2245/// The status of the <see cref="Socket"/> based on the polling mode value passed in the <paramref name="mode"/> parameter.
2256/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> has been closed.</exception>
2261/// <param name="checkRead">An <see cref="IList"/> of <see cref="Socket"/> instances to check for readability.</param>
2262/// <param name="checkWrite">An <see cref="IList"/> of <see cref="Socket"/> instances to check for writability.</param>
2263/// <param name="checkError">An <see cref="IList"/> of <see cref="Socket"/> instances to check for errors.</param>
2301/// <param name="checkRead">An <see cref="IList"/> of <see cref="Socket"/> instances to check for readability.</param>
2302/// <param name="checkWrite">An <see cref="IList"/> of <see cref="Socket"/> instances to check for writability.</param>
2303/// <param name="checkError">An <see cref="IList"/> of <see cref="Socket"/> instances to check for errors.</param>
2592public Socket EndAccept(IAsyncResult asyncResult) => TaskToAsyncResult.End<Socket>(asyncResult);
2597private async Task<(Socket s, byte[] buffer, int bytesReceived)> AcceptAndReceiveHelperAsync(Socket? acceptSocket, int receiveSize)
2601Socket s = await AcceptAsync(acceptSocket).ConfigureAwait(false);
2630public IAsyncResult BeginAccept(Socket? acceptSocket, int receiveSize, AsyncCallback? callback, object? state) =>
2633public Socket EndAccept(out byte[] buffer, IAsyncResult asyncResult)
2635Socket socket = EndAccept(out byte[] innerBuffer, out int bytesTransferred, asyncResult);
2641public Socket EndAccept(out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult)
2643Socket s;
2644(s, buffer, bytesTransferred) = TaskToAsyncResult.End<(Socket, byte[], int)>(asyncResult);
2843Socket? attemptSocket = dnsEP.AddressFamily != AddressFamily.Unspecified ? new Socket(dnsEP.AddressFamily, socketType, protocolType) : null;
2858Socket attemptSocket = new Socket(endPointSnapshot.AddressFamily, socketType, protocolType);
3603internal Socket CreateAcceptSocket(SafeSocketHandle fd, EndPoint remoteEP)
3607Socket socket = new Socket(fd, loadPropertiesFromHandle: false);
3611internal Socket UpdateAcceptSocket(Socket socket, EndPoint remoteEP)
3875Socket socket = (Socket)socketList[i]!;
System\Net\Sockets\Socket.Tasks.cs (40)
32public Task<Socket> AcceptAsync() => AcceptAsync((Socket?)null, CancellationToken.None).AsTask();
39public ValueTask<Socket> AcceptAsync(CancellationToken cancellationToken) => AcceptAsync((Socket?)null, cancellationToken);
46public Task<Socket> AcceptAsync(Socket? acceptSocket) => AcceptAsync(acceptSocket, CancellationToken.None).AsTask();
54public ValueTask<Socket> AcceptAsync(Socket? acceptSocket, CancellationToken cancellationToken)
58return ValueTask.FromCanceled<Socket>(cancellationToken);
352saea.Completed += (s, e) => CompleteSendReceive((Socket)s!, (TaskSocketAsyncEventArgs<int>)e, isReceive: true);
616saea.Completed += (s, e) => CompleteSendReceive((Socket)s!, (TaskSocketAsyncEventArgs<int>)e, isReceive: false);
725/// Sends the file <paramref name="fileName"/> to a connected <see cref="Socket"/> object.
729/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception>
730/// <exception cref="NotSupportedException">The <see cref="Socket"/> object is not connected to a remote host.</exception>
739/// Sends the file <paramref name="fileName"/> and buffers of data to a connected <see cref="Socket"/> object
747/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception>
748/// <exception cref="NotSupportedException">The <see cref="Socket"/> object is not connected to a remote host.</exception>
894private static void CompleteSendReceive(Socket s, TaskSocketAsyncEventArgs<int> saea, bool isReceive)
999internal sealed class AwaitableSocketAsyncEventArgs : SocketAsyncEventArgs, IValueTaskSource, IValueTaskSource<int>, IValueTaskSource<Socket>, IValueTaskSource<SocketReceiveFromResult>, IValueTaskSource<SocketReceiveMessageFromResult>
1002private readonly Socket _owner;
1011public AwaitableSocketAsyncEventArgs(Socket owner, bool isReceiveForCaching) :
1043public ValueTask<Socket> AcceptAsync(Socket socket, CancellationToken cancellationToken)
1048return new ValueTask<Socket>(this, _mrvtsc.Version);
1051Socket acceptSocket = AcceptSocket!;
1059new ValueTask<Socket>(acceptSocket) :
1060ValueTask.FromException<Socket>(CreateException(error));
1065public ValueTask<int> ReceiveAsync(Socket socket, CancellationToken cancellationToken)
1083public ValueTask<SocketReceiveFromResult> ReceiveFromAsync(Socket socket, CancellationToken cancellationToken)
1102internal ValueTask<int> ReceiveFromSocketAddressAsync(Socket socket, CancellationToken cancellationToken)
1120public ValueTask<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(Socket socket, CancellationToken cancellationToken)
1143public ValueTask<int> SendAsync(Socket socket, CancellationToken cancellationToken)
1161public ValueTask SendAsyncForNetworkStream(Socket socket, CancellationToken cancellationToken)
1178public ValueTask SendPacketsAsync(Socket socket, CancellationToken cancellationToken)
1195public ValueTask<int> SendToAsync(Socket socket, CancellationToken cancellationToken)
1213public ValueTask ConnectAsync(Socket socket)
1237public ValueTask DisconnectAsync(Socket socket, CancellationToken cancellationToken)
1306Socket IValueTaskSource<Socket>.GetResult(short token)
1314Socket acceptSocket = AcceptSocket!;
System\Net\Sockets\SocketAsyncEventArgs.Unix.cs (7)
47internal unsafe SocketError DoOperationAccept(Socket _ /*socket*/, SafeSocketHandle handle, SafeSocketHandle? acceptHandle, CancellationToken cancellationToken)
75internal unsafe SocketError DoOperationConnectEx(Socket _ /*socket*/, SafeSocketHandle handle)
95internal SocketError DoOperationDisconnect(Socket socket, SafeSocketHandle handle, CancellationToken _ /*cancellationToken*/)
197internal unsafe SocketError DoOperationReceiveMessageFrom(Socket socket, SafeSocketHandle handle, CancellationToken cancellationToken)
204Socket.GetIPProtocolInformation(socket.AddressFamily, _socketAddress!, out isIPv4, out isIPv6);
245internal SocketError DoOperationSendPackets(Socket socket, SafeSocketHandle _1 /*handle*/, CancellationToken cancellationToken)
351Socket acceptedSocket = _currentSocket!.CreateAcceptSocket(
System\Net\Sockets\SocketPal.Unix.cs (20)
33public static void CheckDualModePacketInfoSupport(Socket socket)
1283public static SocketError ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, byte[] buffer, int offset, int count, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred)
1288Socket.GetIPProtocolInformation(socket.AddressFamily, socketAddress, out isIPv4, out isIPv6);
1309public static SocketError ReceiveMessageFrom(Socket socket, SafeSocketHandle handle, Span<byte> buffer, ref SocketFlags socketFlags, SocketAddress socketAddress, out SocketAddress receiveAddress, out IPPacketInformation ipPacketInformation, out int bytesTransferred)
1314Socket.GetIPProtocolInformation(socket.AddressFamily, socketAddress, out isIPv4, out isIPv6);
1562public static void SetReceivingDualModeIPv4PacketInformation(Socket socket)
1573public static void SetIPProtectionLevel(Socket socket, SocketOptionLevel optionLevel, int protectionLevel)
1842Socket.SocketListDangerousReleaseRefs(checkRead, ref refsAdded);
1843Socket.SocketListDangerousReleaseRefs(checkWrite, ref refsAdded);
1844Socket.SocketListDangerousReleaseRefs(checkError, ref refsAdded);
1863Socket.SocketListDangerousReleaseRefs(checkRead, ref refsAdded);
1864Socket.SocketListDangerousReleaseRefs(checkWrite, ref refsAdded);
1865Socket.SocketListDangerousReleaseRefs(checkError, ref refsAdded);
1881Socket? socket = socketList[i] as Socket;
1884throw new ArgumentException(SR.Format(SR.net_sockets_select, socket?.GetType().FullName ?? "null", typeof(Socket).FullName), nameof(socketList));
1918Socket socket = (Socket)socketList[i]!;
1959Socket socket, TransmitFileOptions options, SendPacketsElement[] elements, SafeFileHandle[] fileHandles, CancellationToken cancellationToken, Action<long, SocketError> callback)
2034internal static SocketError Disconnect(Socket socket, SafeSocketHandle handle, bool reuseSocket)
System\Net\Sockets\SocketTaskExtensions.cs (22)
15public static Task<Socket> AcceptAsync(this Socket socket) =>
18public static Task<Socket> AcceptAsync(this Socket socket, Socket? acceptSocket) =>
22public static Task ConnectAsync(this Socket socket, EndPoint remoteEP) =>
25public static ValueTask ConnectAsync(this Socket socket, EndPoint remoteEP, CancellationToken cancellationToken) =>
28public static Task ConnectAsync(this Socket socket, IPAddress address, int port) =>
31public static ValueTask ConnectAsync(this Socket socket, IPAddress address, int port, CancellationToken cancellationToken) =>
34public static Task ConnectAsync(this Socket socket, IPAddress[] addresses, int port) =>
37public static ValueTask ConnectAsync(this Socket socket, IPAddress[] addresses, int port, CancellationToken cancellationToken) =>
40public static Task ConnectAsync(this Socket socket, string host, int port) =>
43public static ValueTask ConnectAsync(this Socket socket, string host, int port, CancellationToken cancellationToken) =>
47public static Task<int> ReceiveAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags) =>
50public static ValueTask<int> ReceiveAsync(this Socket socket, Memory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default) =>
53public static Task<int> ReceiveAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags) =>
56public static Task<SocketReceiveFromResult> ReceiveFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint) =>
59public static Task<SocketReceiveMessageFromResult> ReceiveMessageFromAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEndPoint) =>
63public static Task<int> SendAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags) =>
66public static ValueTask<int> SendAsync(this Socket socket, ReadOnlyMemory<byte> buffer, SocketFlags socketFlags, CancellationToken cancellationToken = default) =>
69public static Task<int> SendAsync(this Socket socket, IList<ArraySegment<byte>> buffers, SocketFlags socketFlags) =>
73public static Task<int> SendToAsync(this Socket socket, ArraySegment<byte> buffer, SocketFlags socketFlags, EndPoint remoteEP) =>
System.ServiceModel.NetTcp (6)
System.ServiceModel.UnixDomainSocket (5)