Lab07 - UDP sockets
Due:
Wed, Apr 27, 2022 at 11:59 PM
to Github Classroom Assignment
Requirements
- In order to build a chat app, we will learn about using UDP sockets to broadcast online presence.
- You will write a client program using
socket()
,setsockopt()
, andsendto()
to broadcast your presence to any servers on the CSLabs subnet. We will discuss how to use those socket API calls. - You will adapt the server program I showed in lecture to listen for presence messages.
- In your assignment repo, please submit one
Makefile
which builds a client calledclient
and a server calledserver
- Your client should broadcast an online message to to the subnet, sleep for two seconds, then broadcast an offline message to the subnet.
- Your server should print the presence messages it receives
Network Specs
- The CSLabs subnet includes all of the
vlabNN
hosts and theg12NN
hosts. Do not use thekudlickNN
hosts as they are on a different network. - The UDP broadcast address for the CSLabs subnet is
10.10.13.255
. - For our project, we will use port
8221
for online presence messages.
Sample Output
phpeterson@vlab01:lab07 $ ./server
phpeterson@vlab00:lab07 $ ./client phpeterson
online: phpeterson
offline: phpeterson
Now the server should output:
Presence: online: phpeterson on host host: vlab00.cs.usfca.edu
Presence: offline: phpeterson on host host: vlab00.cs.usfca.edu
Rubric
- 70 pts: client broadcasts correctly
- 20 pts: server listens correctly
- 10 pts: neatness, including error handling