---
title: "How I wrote a TCP server in C from scratch · Arpit Solanki"
description: "Notes from building a TCP server in C: networking theory, system calls, Windows vs Linux, and why C."
url: https://arpitsolanki.in/blog/tcp-server-in-c.html
---

Canonical page: https://arpitsolanki.in/blog/tcp-server-in-c.html

[← all posts](https://arpitsolanki.in/blog.html)

# How I wrote a TCP server in C from scratch

2 nov 2025 · ~1 min · first posted on [LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7390750445792591872/)

How I wrote a TCP server in C from scratch ....

-> first I deep dived into TCP theory and all the terminologies involved, medium blogs came helpful, and a bunch of Youtube videos on TCP and networking (yt is the savior at the end of the day) -> Got to learn the concepts of networking and how things work under the hood. Realized frameworks abstract a lot of detail and complexity while doing things. -> After having a grasp of networking jargon and learning about system calls, I faced issues like windows OS had some difference in system calls as compared to Linux and most of the blogs for this are available on Linux based calls, so I continued the project in WSL. -> I realized that C might be an older language, but it gives so much hardware control and modifications at OS level. Concluded "C ain't ordinary". -> Took a lot of help from LLMs as i was unaware of most of the syntax used here from libraries and also got to know about lot of libraries of C related to networking like sys/socket.h, netinet/in.h, arpa/inet.h. -> Why I used C?

- because C is very fast, no garbage collection so no runtime overhead.
- C gives direct access to system calls like socket(), bind(), listen(), and accept()
- there is no layer of abstraction, coding things from scratch feels different 🙂

Github repo - [boss6825/TCP-server-in-C](https://github.com/boss6825/TCP-server-in-C)

I am thinking of scaling it to a multi-client TCP chat server in C using multi-threading will post about this project in future......
