Week 18 Day 1 - Sockets Programming

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=Kdt6GJOpbPQ



Duration: 1:46:08
76 views
1


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.







Tags:
csci 45
sockets programming
java
c world
boost asio
sockets