         tri
     ] with-destructors ;
 
-TUPLE: ssl-handle < disposable file handle connected terminated ;
+TUPLE: ssl-handle < disposable file handle connected ;
 
 SYMBOL: default-secure-context
 


: maybe-handshake ( ssl-handle -- )
    dup connected>> [ drop ] [
        dup terminated>> [
            drop
        ] [
            [ [ do-ssl-accept ] with-timeout ]
            [ t swap connected<< ] bi
        ] if
    ] if ;

! Input ports

        { SSL_ERROR_SSL [ drop throw-ssl-error ] }
        ! https://stackoverflow.com/questions/50223224/ssl-read-returns-ssl-error-zero-return-but-err-get-error-is-0
        ! we got disconnected
        { SSL_ERROR_ZERO_RETURN [ drop f ] }
        { SSL_ERROR_WANT_ACCEPT [ drop +input+ ] }
    } case ;

