Synchronous Chat Program
I'm doing this assignment that's due tomorrow and i don't know what im doing. basically i need to make a C# program where I can connect client and server and be able to chat between the two. So when i send a message in client it goes to server and vice versa. any help would be appreciated. (this is what i have so far)---->
4 Replies
so what are you stuck on?
its like when i start the program it only connects to the client and nothing else. all honesty i dont think its even connected i just need some sort of hint or anything.
i dont understand how to make the two send messages with each other is the main issue i suppose
on the same machine, using a single tcpclient is easiest. There's not really any idea of "server" or "client", it's just read and write on the stream.
if you're running two separate programs, then each basically is a "client", but may differ in how they respond
you can read https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/sockets/tcp-classes for how to accept connections etc
Use TcpClient and TcpListener - .NET
Learn how to use the TcpClient class to create a socket to request and receive data using TCP in .NET.