description

# secureServer method Null safety

Future<SecureSocket> secureServer (

1. Socket socket,
2. SecurityContext? context,
3. {List<int>? bufferedData,
4. bool requestClientCertificate: false,
5. bool requireClientCertificate: false,
6. List<String>? supportedProtocols}

)

Takes an already connected `socket` and starts server side TLS handshake to make the communication secure. When the returned future completes the SecureSocket has completed the TLS handshake. Using this function requires that the other end of the connection is going to start the TLS handshake.

If the `socket` already has a subscription, this subscription will no longer receive and events. In most cases calling `pause` on this subscription before starting TLS handshake is the right thing to do.

If some of the data of the TLS handshake has already been read from the socket this data can be passed in the `bufferedData` parameter. This data will be processed before any other data available on the socket.

See SecureServerSocket.bind for more information on the arguments.

## Implementation

    static Future<SecureSocket> secureServer(
        Socket socket, SecurityContext? context,
        {List<int>? bufferedData,
        bool requestClientCertificate: false,
        bool requireClientCertificate: false,
        List<String>? supportedProtocols}) {
      return ((socket as dynamic /*_Socket*/)._detachRaw() as Future)
          .then<RawSecureSocket>((detachedRaw) {
        return RawSecureSocket.secureServer(detachedRaw[0] as RawSocket, context,
            subscription: detachedRaw[1] as StreamSubscription<RawSocketEvent>?,
            bufferedData: bufferedData,
            requestClientCertificate: requestClientCertificate,
            requireClientCertificate: requireClientCertificate,
            supportedProtocols: supportedProtocols);
      }).then<SecureSocket>((raw) => new SecureSocket._(raw));
    }