/// <summary>
        /// Receive a string from <paramref name="socket"/> asynchronously.
        /// </summary>
        /// <param name="socket">The socket to receive from.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
        /// <returns>The content of the received message.</returns>
        /// <exception cref="System.OperationCanceledException">The token has had cancellation requested.</exception>
        public static ValueTask <string> ReceiveStringAsync(this IThreadSafeInSocket socket,
                                                            CancellationToken cancellationToken = default)
        {
            if (TryReceiveString(socket, out var msg))
            {
                return(new ValueTask <string>(msg));
            }

            // TODO: this is a hack, eventually we need kind of IO ThreadPool for thread-safe socket to wait on asynchronously
            // and probably implement IValueTaskSource
            return(new ValueTask <string>(Task.Factory.StartNew(() => socket.ReceiveString(cancellationToken),
                                                                cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default)));
        }
 /// <summary>
 /// Receive a string from <paramref name="socket"/>, blocking until one arrives, and decode using <see cref="SendReceiveConstants.DefaultEncoding"/>.
 /// </summary>
 /// <param name="socket">The socket to receive from.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>The content of the received message.</returns>
 /// <exception cref="System.OperationCanceledException">The token has had cancellation requested.</exception>
 public static string ReceiveString(this IThreadSafeInSocket socket,
                                    CancellationToken cancellationToken = default)
 {
     return(socket.ReceiveString(SendReceiveConstants.DefaultEncoding, cancellationToken));
 }