TCP Client and Server in C: A Working Echo Example
Setting up a TCP connection takes six system calls. Using it correctly means handling a byte stream with no message boundaries and partial transfers.
C is one of the most important programming languages ever created. Developed in the early 1970s, it remains the foundation of operating systems, embedded systems, compilers, and high-performance software used across the world today. Learning C gives you a deep understanding of how computers actually work — memory, pointers, data structures, and low-level system operations that higher-level languages hide from you.
At MYCPLUS we have been publishing C programming tutorials, source code examples, and practical guides since 2004. Whether you are writing your first Hello World program or working through complex data structure implementations, this section covers every stage of the C learning journey. You will find step-by-step tutorials, working source code you can compile and run immediately, and clear explanations of concepts that are often poorly explained elsewhere.
C is the language that powers Linux, Windows internals, embedded microcontrollers, game engines, and countless performance-critical applications. If you want to become a serious systems programmer, understand how memory works, or simply build a rock-solid foundation before moving to C++, Java or Python — start here.
Why MYCPLUS Trusted by C programmers since 2004 — every tutorial includes working source code you can compile, run and learn from immediately.
Setting up a TCP connection takes six system calls. Using it correctly means handling a byte stream with no message boundaries and partial transfers.
The most copied base64 implementation in C has a heap over-read in its own example. Here is a correct one, checked against the RFC 4648 test vectors.
Before it sends a byte, a ping program has to get past the kernel. Portable C for Linux and macOS, the Winsock differences, and all four permission routes.
Only one branch runs, but both decide the type — and that is where printf goes wrong. Tested C examples, plus the MAX macro trap.
A guard stops a header being pasted in twice. It does not stop it being defined twice. Tested examples, captured errors, and the pragma once myths.
The syntax takes a minute. The five ways it goes quietly wrong take longer — and every one of them compiles without an error.
Six conversion functions are really two algorithms. A tested base converter for every base from 2 to 36, and what the old menu program got wrong.
scanf(“%s”) wrote 31 bytes into an 8-byte buffer. A guide to C I/O that shows the unsafe patterns failing rather than just naming them.
Why == silently fails on C strings, how to read strcmp’s return value correctly, and the safe input pattern the comparison depends on.
Why writing to one of these two identical-looking declarations crashes, what array decay does to sizeof, and what std::string changes.
The same four members reordered went from 24 bytes to 16. A guide to struct syntax, what the compiler does with your layout, and why memcmp lies.
Arithmetic to bitwise, with the complete precedence table and the conversion rules that quietly change your operands before the operation runs.