How to Compile and Run the SmallChat C Server from GitHub
This guide shows how to clone the SmallChat repository, compile the C source with gcc, launch the server binary, and connect via telnet to test the default 7771 port, including code snippets and command‑line examples.
Repository
Source code: https://github.com/antirez/smallchat
git clone [email protected]:Tinywan/smallchat.gitCompilation
Compile the single source file with gcc:
cd smallchat/
gcc -o smallchat smallchat.cThe -o option sets the output file name ( smallchat ); smallchat.c is the source file.
ls
Makefile README.md smallchat smallchat.cRunning the Server
./smallchatThe server listens on port 7771 by default. To change the port, edit the constant #define SERVER_PORT 7711 in the source code and recompile.
Connecting with Telnet
telnet 127.0.0.1 7711After connecting, set a nickname with /nick <nick> and start sending messages.
Terminal 1
telnet 127.0.0.1 7711
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Welcome to Simple Chat! Use /nick <nick> to set your nick.
/nick tinywan001
This is just a programming example (tinywan001)Terminal 2
telnet 127.0.0.1 7711
... (connection steps) ...
/nick tinywan002
Since I wrote this little program (tinywan002)Server Output
./smallchat
Connected client fd=4
Connected client fd=5
tinywan002> Since I wrote this little program (tinywan002)
tinywan001> This is just a programming example (tinywan001)
... (message exchange) ...
Disconnected client fd=5, nick=tinywan002
Disconnected client fd=4, nick=tinywan001Telnet Command Overview
Basic syntax: telnet ip_address port Replace ip_address with the target host and port with the service port (e.g., 7711).
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
