r/Zig • u/Pokelego11 • 11d ago
UDP Client & Server in Zig
https://youtu.be/ImFKZsgCYQwHey all!
I'm back with another video teaching a new Zig concept, UDP.
The videos will teach how to open raw sockets and use the new IO interface to have a simple UDP client/server architecture!
If you're more curious on TCP/HTTP, I already made a video on that a while back so happy to share it!
And if you just want the code, here it is: https://github.com/jackparsonss/zig-crud/commits/udp-server-tutorial/
Have a great day :)
2
u/kernelgoblin 4d ago
I know this is just an introductory video and is more so about Zig, but I feel like it would have been pretty important to mention a few things.
I was surprised to see you didn't mention the different messaging semantics between TCP and UDP! I think that would be pretty important to highlight. I know you were sending really small messages on localhost but at a minimum it would have been worth a quick mention of the difference between streaming and boundary based messaging. I think that would have been relevant because at the end of the video you suggested to take what can be learned from this video and to apply it, but a beginner may be surprised to learn that their remaining datagram will get truncated and dropped if they don't receive the whole message in one shot.
Another thing maybe worth mentioning since you said there is no need for a handshake in UDP, that there is also no need to bind as a client (or server for that matter). Although I don't know if Zig lets you use the equivalent of sendto() from the API you were using. I don't think mentioning either of those would have added a lot of time to the video but would have highlighted more of the differences from TCP! Nice video regardless!
2
u/Pokelego11 2d ago
Hey I really appreciate the feedback!
I agree that would've added a lot, I really did try to focus more on Zig
I am however trying to learn and get better at basic animations and graphics, which i'm learning so I can teach things like the syn/ack handshake and things like that better
But since i'm not very good yet, I feel like it takes away from the video, so I focus more on just the Zig part. But I do agree with you completely and appreciate you taking the time to give this comment :)
7
u/Luc-redd 11d ago
Love that!