Repository: dotnet/runtime
File: src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs (C#)

Code before:
                {
                    // ConnectEx supports connection-oriented sockets but not UDS. The socket must be bound before calling ConnectEx.
                    bool canUseConnectEx = _socketType == SocketType.Stream && endPointSnapshot.AddressFamily != AddressFamily.Unix;
                    SocketError socketError = canUseConnectEx ?
                        e.DoOperationConnectEx(this, _handle) :
                        e.DoOperationConnect(_handle); // For connectionless protocols, Connect is not an I/O call.
                    pending = socketError == SocketError.IOPending;
                }
                catch (Exception ex)
                {
                    SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message);
                    e.ConnectActivity = null;

                    _localEndPoint = null;

                    // Clear in-use flag on event args object.
                    e.Complete();
                    throw;
                }
            }

            return pending;
        }

        public static bool ConnectAsync(SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e) =>
                            ConnectAsync(socketType, protocolType,  e, ConnectAlgorithm.Default);
        public static bool ConnectAsync(SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e, ConnectAlgorithm connectAlgorithm)
        {
            ArgumentNullException.ThrowIfNull(e);
            if (connectAlgorithm != ConnectAlgorithm.Default &&
                connectAlgorithm != ConnectAlgorithm.Parallel)
            {
                throw new ArgumentException(SR.Format(SR.net_sockets_invalid_connect_algorithm, connectAlgorithm), nameof(connectAlgorithm));
            }

            if (e.HasMultipleBuffers)
            {
                throw new ArgumentException(SR.net_multibuffernotsupported, nameof(e));
            }
            if (e.RemoteEndPoint == null)
            {
                throw new ArgumentException(SR.Format(SR.InvalidNullArgument, "e.RemoteEndPoint"), nameof(e));
            }

            EndPoint endPointSnapshot = e.RemoteEndPoint;
            DnsEndPoint? dnsEP = endPointSnapshot as DnsEndPoint;

            bool pending;
            if (dnsEP != null)
            {
                Socket? attemptSocket = dnsEP.AddressFamily != AddressFamily.Unspecified ? new Socket(dnsEP.AddressFamily, socketType, protocolType) : null;

Review comment (suggestion):
Nit: formatting.

```suggestion
        public static bool ConnectAsync(SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e) =>
            ConnectAsync(socketType, protocolType,  e, ConnectAlgorithm.Default);

```

Code after:
                    e.StartOperationConnect(saeaMultiConnectCancelable: false, userSocket);
                }
                catch (Exception ex)
                {
                    SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message);
                    e.ConnectActivity = null;
                    throw;
                }

                // Make the native call.
                try
                {
                    // ConnectEx supports connection-oriented sockets but not UDS. The socket must be bound before calling ConnectEx.
                    bool canUseConnectEx = _socketType == SocketType.Stream && endPointSnapshot.AddressFamily != AddressFamily.Unix;
                    SocketError socketError = canUseConnectEx ?
                        e.DoOperationConnectEx(this, _handle, cancellationToken) :
                        e.DoOperationConnect(_handle, cancellationToken); // For connectionless protocols, Connect is not an I/O call.
                    pending = socketError == SocketError.IOPending;
                }
                catch (Exception ex)
                {
                    SocketsTelemetry.Log.AfterConnect(SocketError.NotSocket, e.ConnectActivity, ex.Message);
                    e.ConnectActivity = null;

                    _localEndPoint = null;

                    // Clear in-use flag on event args object.
                    e.Complete();
                    throw;
                }
            }

            return pending;
        }

        public static bool ConnectAsync(SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e) =>
                            ConnectAsync(socketType, protocolType, e, ConnectAlgorithm.Default);
        public static bool ConnectAsync(SocketType socketType, ProtocolType protocolType, SocketAsyncEventArgs e, ConnectAlgorithm connectAlgorithm)
        {
            ArgumentNullException.ThrowIfNull(e);
            if (connectAlgorithm != ConnectAlgorithm.Default &&
                connectAlgorithm != ConnectAlgorithm.Parallel)
            {
                throw new ArgumentException(SR.Format(SR.net_sockets_invalid_connect_algorithm, connectAlgorithm), nameof(connectAlgorithm));
            }

            if (e.HasMultipleBuffers)
            {
                throw new ArgumentException(SR.net_multibuffernotsupported, nameof(e));
            }
            if (e.RemoteEndPoint == null)