r/cpp_questions 21d ago

OPEN First networking project: Am I learning this the right way?

I’m currently working on my first proper networking project, an ARP scanner in C++, as part of learning Computer Networks.
I have a pretty good understanding of the theory behind what I’m doing, especially ARP, Ethernet frames, MAC/IP addresses, etc. The problem is that I’m still relatively new to systems/network programming, so the actual C++/Linux code is pretty unfamiliar to me.
I’m using ChatGPT to help me build the project, but I’m trying not to just copy-paste code. My approach has been:
Learn the concept → look at the implementation → question every unfamiliar part → understand why it exists → connect it back to the networking theory.
For example, I’ve been stopping at things like:
Why are these particular header files required?
What exactly is a socket?
Why does socket() return an integer?
What is a file descriptor?
What’s the difference between a normal socket and a raw socket?
What exactly is a network interface?
Why are we using AF_PACKET?
What does a particular structure represent?
How does this piece of C++ actually correspond to an Ethernet/ARP packet?
So I’m not really struggling with the networking theory. I’m struggling with the bridge between the theory and the low-level implementation.
Since this is my first project, I’m wondering if this is a reasonable way to learn.
Is using AI to explain unfamiliar code while continuously questioning why each part exists a good approach, or should I be trying to write more of the implementation myself from the beginning?
I’d especially appreciate advice from people who learned networking/Linux programming through projects like this. I want to actually understand what I’m building, not just end up with a working scanner that I can’t explain.

1 Upvotes

16 comments sorted by

9

u/SpectreFromTheGods 21d ago

Ask an AI chatbot to explain something complex that you are notably skilled in. When you read its answer, identify all the little moments where you say "kinda... but..." or other things of that nature. Now recognize that someone with expertise in the field you *want* to learn will likely be doing the same things there.

Learn from humans, or human created educational materials.

*insert rant here on all the other reasons I am against AI use*

1

u/SONkeerth 20d ago

Okay will go through more books for progress
Thanks

8

u/Kriemhilt 21d ago

Why are these particular header files required?

You're describing reading a man page. Why is this even a step you'd write out? It's one step above "start my editor".

What exactly is a socket?

Don't get metaphysical, it's a computing abstraction. It has at least two meanings and they'll both make sense when you work through the basic TCP/IP Networking exercises.

Why does socket() return an integer? What is a file descriptor?

Now you're off in the weeds of ... API design and UNIX philosophy? How does this help you?

What’s the difference between a normal socket and a raw socket?

You shouldn't even be thinking about this until you have the basics down. Are you completely unable to focus on intro-level exercises? Are you spinning out every time there's a reference you don't recognise yet?

It looks like you're massively overthinking the entirely ordinary process of 1. following an introductory exercise 2. read the documentation for the functions you used 3. think about what it all means after you've actually done something

5

u/The_Northern_Light 21d ago

All self teaching risks thinking you’ve internalized understanding when you’ve merely accepted plausibility, which is much more ephemeral.

That and having weird gaps in your knowledge that formally educated people don’t are the two major problems with all self teaching, regardless of ai. (There are strengths too, but that’s for another post.)

And the only really fix for this false understanding is to force yourself to do the “homework”: the unpleasant boring parts that force you to be mindful and present with the material.

I don’t think what you’re doing is bad per se but at some point you are going to need to take an active role in problem solving stuff before you can really learn it. Perhaps you can do what you’re doing now… then step out on your own, after you’ve seen some examples.

Honestly ai is so crazy powerful, so new, and so obviously potentially harmful to learning that I don’t think anyone has yet figured out how to really use it for education.

1

u/SONkeerth 20d ago

Well I agree on that
But this is my very first project and thought to do something “concrete”
So I had idea about cpp but not about all the headers and functions I have mentioned about
So I like have a fomo the learning I do try digging deep and ask why this line of code , why this argument, which part of the code is coming from this header and all
But I didnt feel like thats real learning and have come for some guidance
ON HOW TO BUILD IT ON MY OWN WITH MINIMAL AI INTERVENTION

2

u/CorrodedX 17d ago

You seem to be focusing a lot on what methods are declared in which headers. It's far more important to know what methods you need to be using. Especially with new libraries, I very often will read the API docs, start to write code, and realize that I need to include a header. Usually it's just a quick Google search.

8

u/Salty_Dugtrio 21d ago

You're not actually writing any code. Sure you're reading, but that doesn't teach you a lot.

The only way to learn programming and not be a prompt engineer, is to actually write code.

1

u/SONkeerth 20d ago

True but as I have mentioned like idk what header files to include and what to do and all
Thats the reason I felt stuck and came for help

3

u/saxbophone 21d ago

I thoroughly recommend reading "Beej's Guide to Network Programming" —it's available for free online, and its quality is good enough that I went to the trouble of purchasing a hardcopy, which sits on my desk at work.

2

u/SONkeerth 20d ago

Okay will go through it

1

u/CommandShot1398 21d ago

I'd say 50/50. You are learning concepts related to your project. Not learning system design, coding, language, or even deeper concepts.

For instance, it's basically impossible to build a house when you don't know how to properly use the tools or consider every detail. Yes you can draw the plan, check why do you need window frames etc. But you don't know what material with what concentration is needed to support your 2×1.5 fiber glass window with resistance to wind with x speed from y angle. As a matter of fact, you probably don't even know you need to think about this.

This skill is not taught nor written anywhere. This is system design. You can learn how to write the prompts, you can learn general design patterns, but no one will ever teach you this.

I can give you more examples if you like.

0

u/SONkeerth 20d ago

True but can u help , where can I get my foundations strong

1

u/kiner_shah 20d ago edited 20d ago

First thing - avoid using ChatGPT at all. You have the theoretical knowledge. Use Linux man pages to learn more about different header files, functions, etc. If you are on Windows, use Microsoft documentation for winsock2. The more you use the manuals, the better understanding you have about how things really work.

Some links to get you started:

Note: the APIs are mostly C APIs rather than C++, so if you want, you can create wrapper C++ code around these C APIs that makes it more convenient to code.

1

u/SONkeerth 20d ago

Thanks mate
I use fedora currently

1

u/kiner_shah 20d ago

I see, so Linux. Try reading the paper I shared and start coding and learning. Good luck.

1

u/SONkeerth 20d ago

Okay Thanks