Name:______________________________ Alpha:________________________________
Print this page and give the answers.
- [10pts]
You are given an integer x that is an 8-bit number (i.e., x is between 0 and
255).
- How would you flip the first 4 bits of x?
- How would you change the last 4 bits of x to be all 1s?
- [10pts] Bob would like to connect to Alice and have a netcat chat with him.
Alice's IP address is 100.101.102.103, and she will listen at UDP port 9876.
Give a terminal command for each of Alice and Bob. (Note: Understand every
detail correctly so you don't miss anything)
- [8pts] For a TCP server socket, you need to do the following.
- Create a socket by calling ___________________.
- You need to _________________ the socket to a specific port so that the
clients can connect the server by using that specific port.
- Call ________________ to look for any connection attempt from a remote
client.
- Now, you can _______________ any connection request.
- [12pts] For a TCP client socket, you need to do the following.
- Create a socket by calling _________________.
- Connect to a server by calling _________________.
- Use _______________ and ________________. You need to use
the data of ___________________ type.
- Close the socket by calling ________________.
Submission deadline
Check the course calendar for the deadline. Bring your work to class.