Week 18 Day 1 - Sockets Programming
Today we went over how to do Sockets programming in a few different ways:
1) C - I showed how to do sockets programming using the C (and C++, sadly) standard library. The socket() call creates a file descriptor (fd) that you can read and write to, and there's functions that let you know which sockets have data ready to be read from. I went through the Accept/Listen process on the server side to get a new fd to talk to the client, and then how I parsed the strings coming in from the client (using some pointer tricks) and sending data back to the client.
2) Java - Java has a nice standard library when it comes to networking. You make a Socket or ServerSocket, and then can turn the socket into something that works just like System.out or System.in in terms of reading and writing to it. I showed a multithreaded server as well.
3) C++ - the Boost ASIO library is the closest thing to a C++ standard library sockets implementation that we have. There's a few different options for doing sockets programming with ASIO, so what I showed today was the iostream version that lets you write to the network as easily as you can write to cin/cout or a file. Like with ifstreams (file streams in C++), there's just a little bit of setup needed to get the thing to connect over the internet.
Other Videos By Bill Kerney
2021-07-07 | Week 1 Lecture 2 - Intro to Unreal Engine |
2021-07-07 | Week 1 Day 1 - Welcome to IS50A |
2021-05-15 | Week 18 - Bounding Volume Hierarchies |
2021-05-14 | Week 18 Day 3 - Use Cases |
2021-05-13 | Week 18 Day 2 - Final Presentations |
2021-05-13 | Week 18 Day 2 - Hyperthreading |
2021-05-12 | Week 18 Day 2 - Graph Adjacency Lists |
2021-05-12 | CSCI 41 Study Session: BSTs |
2021-05-12 | Week 17 Day 2 - The Development Process and AI |
2021-05-11 | Week 18 Day 1 - Shaders, Rasterization |
2021-05-11 | Week 18 Day 1 - Sockets Programming |
2021-05-10 | Week 18 Day 1 - EC, BST deletes, Graphs |
2021-05-08 | Week 17 - Making a 2.5D Game (Wolfenstein-style) from Scratch |
2021-05-08 | Week 17 Day 3 - Circular Arrays |
2021-05-07 | Week 17 Day 2 - Being a Sysadmin |
2021-05-05 | Week 17 Day 2 - Threads and Sockets Part II |
2021-05-05 | Week 16 Day 2 - Final Review |
2021-05-04 | Week 17 Day 1 - Relays and Transistors |
2021-05-04 | Week 16 Day 1 - Netiquette |
2021-05-03 | Week 17 Day 1 - Threads and Sockets Programming |
2021-04-30 | Week 16 Day 3 - Java Part II |