How does a beginner go about learn networking basics as well as being able to apply some network programming concepts using Golang? I do know the basics of Golang but I have no idea where to start with the networking bit, I have heard of the OSI model but I am not sure if it is a proper way to understand networking.
Hey there – I had the same question a while back and compiled a list of resources/curriculum to learn networking, using Go. You can find everything here. I think once you get the networking concepts down (using for example Beej’s guide). You can translate the C code into Go code (Go in fact just makes the same system calls, with some layers of abstraction on top) and will be well on your way!
Thank you! I think this is exactly what I am looking for.
It depends how you learn best. Go is already fairly high-level.
Here are a few things I would play with:
That should be enough for day-to-day programming. I also encourage you to read up on how DHCP, ICMP, TCP/IP, DNS resolution works. And higher-level protocols such as HTTP.
Thank you, do you have any ideas for little projects I could do after I am done learning the basics and have played around with the implementations?
You could write a little file-sending tool.
You need a client mode that opens the file and tries to forward it to a server. For example the usage could be
filecli send <filename> <targethost[:port]>
Eg:filecli send /etc/password myserver:8848
.You need a server that accepts new client connections and puts the file in a per-determined location. For example the usage could be
filecli recv <bind-addr:[port]> <directory>
. Eg:filecli recv 0.0.0.0:8848 ./Downloads
.At first you just want to get the raw data for each connection and store them into incremental names. Eg: ~/Download/file-1 ~/Downloads/file2. Each connection can only send one file and the file is closed at the same time as the connection.
Once you have that, think about what issues the implementation has and how you could augment it, maybe by creating some sort of exchange protocol yourself. What happens if the connection gets interrupted during the transfer.
Implement a protocol, use the Go documation, avoid frameworks or anything like that, because then you will only learn that framework. It also helps to be able to read specifications, whether it’s an RFC or not. Good luck with that! :)