4 ms·
Introduction to TCP and Sockets (2001)
- 29athrowaway 4y agoBeej's Guide to Network Programming Using Internet Sockets https://beej.us/guide/bgnet/ https://beej.us/guide/bgnet/
- Waterluvian 4y agoIf I want to implement some rudimentary communications protocol between two machines in Rust, just for learning, is this where I should begin? Edit: perhaps not quite. Seems like this lives “on top of” TCP or UDP. I should probably read through this then look for something like a “how to implement ICMP” guide.
- tyingq 4y agoThis seems close to what you're asking for: https://github.com/smoltcp-rs/smoltcp https://github.com/smoltcp-rs/smoltcp A small-ish tcp/ip stack, in rust, that can use TAP so you're down in the weeds making the packets.
- deleted 4y ago[deleted]
- mr_toad 4y agohttps://en.wikipedia.org/wiki/UNIX_Network_Programming https://en.wikipedia.org/wiki/UNIX_Network_Programming Or maybe https://en.wikipedia.org/wiki/TCP/IP_Illustrated https://en.wikipedia.org/wiki/TCP/IP_Illustrated if you need to get down to the packet level.
- achillean 4y agoLove this guide. It's what got me started with network programming.
- silisili 4y agoSame. It is my single favorite piece of programming literature that exists, and I'm an avid reader! If anyone cares, 'Code' is a close second. Different styles and uses, I'm just judging on utility to me.
- belfalas 4y agoJulia Evans guide is a great companion: https://wizardzines.com/zines/networking/ https://wizardzines.com/zines/networking/ Very different format!
- dragontamer 4y agoI feel like beginner programmers should experiment with the following concepts in order. 1. File I/O to plaintext files. fread/fwrite, or whatever equivalent is in your programming language (Python fd.read() or whatever) is your first step into I/O. Especially because you can open the file and read it yourself as a human. 2. Piped I/O using Unix Pipes and/or Fifos. Pipes (./program1 | ./program2) are by far the easiest interprocess communication mechanism. They're not very flexible, but they're obvious to understand once you have mastered simple File I/O. 3. TCP Sockets are the natural evolution from pipes. Your first TCP Server will not be socket/bind/accept, since this is a bit complicated. Instead, you should write nc -l (port number) | ./myprogram, where netcat does the heavy lifting for you and creates a listening server for ./myprogram. You then have the ability to write ./myclient (which communicates to netcat, and therefore to "myprogram"). 4. You finalize this by writing the server side without the netcat training wheels, to learn the socket/bind/accept dance.
- bigDinosaur 4y agoIMO CS 144 from Stanford is excellent at introducing this level of networking: https://cs144.github.io/ https://cs144.github.io/
- acqbu 4y agosecond that; the videos are on YT https://www.youtube.com/playlist?list=PLoCMsyE1cvdWKsLVyf6cPwCLDIZnOj0NS https://www.youtube.com/playlist?list=PLoCMsyE1cvdWKsLVyf6cP...
- nly 4y agoI disagree that TCP are an evolution of pipes. Pipes are unidirectional and have 2 file descriptors, which is way less confusing than TCPs behaviour with respect to EOF, shutdown and write()/read() error behaviour. A socket API that gave you two unidirectional fd's for a TCP socket would have been a massive improvement.
- WJW 4y agoTCP connections also have 2 file descriptors, they are just on different computers. It seems quite natural to me to think of a socket as two pipes joined together. As with so many things in computing the abstraction leaks a bit when you get deeper into it but as a first intuition for beginners I think you could do way worse than "a socket is a bidirectional pipe to another computer". I'm intrigued by your idea of making 2 file descriptors for each socket btw. Why would it be such an improvement in your opinion?
- danieleggert 4y agoWrote this some years ago: https://www.objc.io/issues/10-syncing-data/ip-tcp-http/ https://www.objc.io/issues/10-syncing-data/ip-tcp-http/
- deleted 4y ago[deleted]
- lurker53 4y agoSuch basic stuff, even first year students should know this...
- cpach 4y agoSure. But keep in mind that some people readers here on HN are still beginners when it comes to TCP/IP. Maybe high school students, maybe they work in another field than tech, maybe they work in tech but with design, legal, HR etc etc. For those readers it could potentially be a useful and interesting resource.
- deleted 4y ago[deleted]
- Pr0ject217 4y agoAs a late-bloomer programmer who hasn't yet found a 'niche' to love, I have a genuine question for those who are passionate about network programming. What attracts you to network programming? Thank you.
- the_only_law 4y agoI just like making things talk to each other, particularly things that were never designed to talk to each other.
- Pr0ject217 4y agoInteresting. If you don't mind me asking, what kinds of things have you made talk to each other that weren't originally designed to talk to each other?
- the_only_law 4y agoUsually make retrocomupters talk to modern networks or modern computers talk to retro networks. Admittedly I haven't programmed much in a while outside work, but have a number of backlogged projects including an H.320 (ISDN videoconferencing spec) to discord bridge. Most of my ideas, are useless and kinda dumb, but fun.
- Pr0ject217 4y agoThe nerd in me thinks it's very cool. :)
- togs 4y agoNAT always confuses me. What do you mean I have two IP addresses why can’t this be simplified?