Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.Net.Sockets;
- using System.Threading;
- namespace Client_ServerChat
- {
- class Klient
- {
- TcpClient klient;
- public Klient()
- {
- klient = new TcpClient();
- try
- {
- klient.Connect("localhost", 8001);
- NetworkStream stream = klient.GetStream();
- while(true)
- {
- byte[] bytes = new byte[klient.ReceiveBufferSize];
- stream.Read(bytes, 0, (int)klient.ReceiveBufferSize);
- string returndata = Encoding.UTF8.GetString(bytes);
- if(returndata.Length > 0)
- Console.WriteLine("This is what the host returned to you: " + returndata);
- Thread.Sleep(300);
- }
- }
- catch(Exception e)
- {
- Console.WriteLine(e);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment