hey ppl I have just a Simple Server/Client application but the messages are not passing correctly
plz help me , Codes are given below
Server
static void Main(string[] args){
IPAddress ipaddr = IPAddress.Parse("127.0.0.1");
IPEndPoint endpoint = new IPEndPoint(ipaddr, 8000);
TcpListener server = new TcpListener(endpoint);
Console.WriteLine("server is Starting");
server.Start();
Console.WriteLine("Waiting for client");
TcpClient sAccepted = server.AcceptTcpClient();
Console.WriteLine("\n\n\nClient Connected");
NetworkStream tcpStream = sAccepted.GetStream();
byte[] bytes = new byte[sAccepted.ReceiveBufferSize];
int bytesRead = tcpStream.Read(bytes, 0, sAccepted.ReceiveBufferSize);
byte[] sendBytes = Encoding.ASCII.GetBytes("text from server");
tcpStream.Write(sendBytes, 0, sendBytes.Length);
}
Client
static void Main(string[] args){
IPAddress ipAddr = IPAddress.Parse("127.0.0.1");
IPEndPoint endPoint = new IPEndPoint(ipAddr,8000);
TcpClient newClient = new TcpClient();
Console.WriteLine("Client is Connecting...");
newClient.Connect(endPoint);
NetworkStream tcpStream = newClient.GetStream();
byte[] sendBytes = Encoding.ASCII.GetBytes("This is a Test<EOF>".ToString());
tcpStream.Write(sendBytes, 0, sendBytes.Length);
byte[] bytes = new byte[newClient.ReceiveBufferSize];
int bytesRead = tcpStream.Read(bytes, 0, newClient.ReceiveBufferSize);
}