public void Start() { _client = new QuicClient(); try { _client.Connect("127.0.0.1", 8880); _stream = _client.CreateStream(); Thread t = new Thread(new ThreadStart(ReceiveMessage)); t.Start(); while (true) { Console.Write("# Your message: "); string input = Console.ReadLine(); string str = _username + ": " + input; int currentLineCursor = Console.CursorTop - 1; Console.SetCursorPosition(0, Console.CursorTop - 1); Console.Write(new string(' ', Console.WindowWidth)); Console.SetCursorPosition(0, currentLineCursor); Console.WriteLine("You: " + input); byte[] b = System.Text.Encoding.UTF8.GetBytes(str); _stream.Write(b, 0, b.Length); } } catch (Exception e) { Console.WriteLine("Couldn't connect to the server port {port}"); Console.WriteLine(e.Message); } }
static void Main(string[] args) { QuicClient client = new QuicClient(); QuicContext context = client.Connect("127.0.0.1", 11000); // Connect to peer (Server) QuicStreamContext sc = client.CreateStream(); // Create a data stream sc.Send(Encoding.UTF8.GetBytes("Hello from Client!")); // Send Data sc.Close(); // Close the stream after processing }