GitHub - Sieep-Coding/simple-chat-csharp: A simple chat server written in C#

2 min read Original article ↗

Simple Chat Server

A terminal-based chat server written in C#.

Warning

Only Tested on Linux PopOS!

License: MIT PopOS Passing wakatime

Server

Listens for connections & messages, logs in real-time.

Client

Steve sends a message to the server.

Nick sends a message to the server.

Guide

Requirements

.NET 9 SDK

Compatible terminal environment (Linux, macOS, Windows)

Running the Server

  • Open a terminal and navigate to the project root directory.
  • Run:
dotnet run --project CSharpStream server
  • The server listens on port 8000 by default.
  • Press Ctrl+C to gracefully stop the server.

Running the Client

  • Open a new terminal window.
  • Run:
dotnet run --project CSharpStream client
  • When prompted, enter your username.
  • Type messages and press Enter to send them to the chat.

Project Structure

  • CSharpStream.Server – TCP server implementation handling client connections and message broadcasting.
  • CSharpStream.Client – TCP client implementation for sending and receiving chat messages.
  • CSharpStream.Models – Contains the Message and User models, used for structured data transfer and managing user identity information.
  • ChatServer.cs - Works as the service layer.
  • Program.cs - Starts client/server based on command line arguments.

Troubleshooting

  • Ensure no firewall or network restrictions block port 8000.
  • If connection is refused, verify the server is running before starting clients.
  • Use Ctrl+C to exit clients and server cleanly.

License

MIT License