C# socket .... ssl stream receiving 0 bytes before getting websocket headers

I am really confused and would like some help clarifying on what is happening.

I have a C# socket server program that accepts websockets.

Everything works fine when I use "new WebSocket(ws://localhost:100,'chat')" to open a new connection.

Normally program will listen for new socket and accept socket asynchronously. After accepting socket I can receive data using BeginReceive and send handshake.

However, when I implement sslstream and use

new WebSocket(wss://localhost:100,'chat')

to start websocket connection. The program behaves differently.

After my program accepts the socket I receive 0 bytes using BeginRead. After which a I have to listen and accept another socket and call BeginRead again to get the websocket headers only then I can send the handshake.

Is this by design or am I missing something?

Below is the relevant code.

private static void listen_new(Socket sock)
{
    try
    {
        Console.WriteLine("Listening Incoming Connnection...");
        sock.Listen(5);
        sock.BeginAccept(new AsyncCallback(start_accept_new), sock);
    }
    catch (SocketException e)
    {
        Console.WriteLine("Socket Error Occurred (Listen New):" + e.Message);
    }
}

private static void start_accept_new(IAsyncResult AR)
{
    try
    {
        Console.WriteLine("Accepting New Connection....");
        Socket sock = ((Socket)AR.AsyncState).EndAccept(AR);
        listen_new((Socket)AR.AsyncState);

        NetworkStream myNetworkStream = new NetworkStream(sock, true);
        SslStream sslStream = new SslStream(myNetworkStream, false);

        try
        {
            sslStream.AuthenticateAsServer(serverCertificate,
            false, SslProtocols.Tls12, true);
            Console.WriteLine("IsAuthenticated: {0}", sslStream.IsAuthenticated);
            sslStream.BeginRead(_buffer, 0, _buffer.Length, ar => { begin_handshake(ar, sock); }, sslStream);
        }
        catch (AuthenticationException e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
            if (e.InnerException != null)
            {
                Console.WriteLine("Inner exception: {0}", e.InnerException.Message);
            }
            Console.WriteLine("Authentication failed - closing the connection.");
            sslStream.Close();
            sock.Close();
            return;
        }
    }
    catch (SocketException e)
    {
        Console.WriteLine("Socket Error Occurred (Start Accept New):" + e.Message);
    }
}

private static void begin_handshake(IAsyncResult AR, Socket sock)
{
    Console.WriteLine("Shaking Hands");
    SslStream sock_stream = ((SslStream)AR.AsyncState);
    int Data = sock_stream.EndRead(AR);
    Console.WriteLine("Data Received"+ Data);

    if (Data != 0)
    {
        byte[] databyte = new byte[Data];
        Array.Copy(_buffer, databyte, Data);

        String text = Encoding.ASCII.GetString(databyte);
        List<string> headers = retriveheaders(text);
        bool headercheck = authenticate_socket(headers);

        if (headercheck == true)
        {
            acceptuser(headers, sock, sock_stream);
        }
        else
        {
            sock_stream.Close();
            sock.Close();
            sock.Dispose();
        }
    }
    else {
        sock.Shutdown(SocketShutdown.Both);
        sock_stream.Close();
        sock.Close();
        sock.Dispose();
    }
}

Currently this code discards the socket if data received is 0 bytes and processes if data received is not 0.