Skip to content

A simple real-time chat application built with Dart using TCP sockets. It allows multiple clients to connect to a central server and exchange messages concurrently.

Notifications You must be signed in to change notification settings

TechieChuks/dart_tcp_chat_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Application CLI (Dart)

A simple real-time chat application built with Dart using TCP sockets. It allows multiple clients to connect to a central server and exchange messages concurrently.


Features

  • TCP server listening on port 4040
  • Multiple clients can join simultaneously
  • Messages are broadcasted to all connected clients
  • CLI-based interaction
  • Type exit to leave chat gracefully

Project Structure

chat_application/
│
├── bin/
│   ├── chat_server.dart   // Server code
│   └── chat_client.dart   // Client code

Usage

Start the Server

dart run bin/chat_server.dart

Start a Client

dart run bin/chat_client.dart

Enter server IP (default 127.0.0.1) and choose a username. Type messages and they will appear in all connected clients.

Exit Chat

Type:

exit

Example Run

Server:

Chat server running on port 4040...
New client connected: 127.0.0.1:60512
Received: Emeks: Hello everyone!
Received: Chuks: Hi Emeks!

Client 1 (Emeks):

Enter server IP (default 127.0.0.1):
Enter your username: Emeks
Connected to chat server at 127.0.0.1:4040
Emeks: Hello everyone!
Chuks: Hi Emeks!

Client 2 (Chuks):

Enter server IP (default 127.0.0.1):
Enter your username: Chuks
Connected to chat server at 127.0.0.1:4040
Emeks: Hello everyone!
Chuks: Hi Emeks!

Concepts Practiced

  • TCP sockets (ServerSocket, Socket)
  • Async I/O with streams (listen)
  • Broadcasting messages to multiple clients
  • Concurrent CLI interaction

Future Improvement

  • Add private messaging between clients
  • Add user join/leave notifications
  • Implement chat history persistence

About

A simple real-time chat application built with Dart using TCP sockets. It allows multiple clients to connect to a central server and exchange messages concurrently.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages