Fall 2018 CSCI 373.001: Unix communication

The working directory

Use the following commands to create a directory that the instructor can access for this assignment.

mkdir -p ~/opsys/sockets
chmod 700 ~/opsys/sockets
setfacl -m u:brock:rx ~/opsys/sockets
ls -ld ~/opsys/sockets
getfacl ~/opsys/sockets
  

Put all your work in this directory.

Example programs for Compare And Swap

Download the following programs into your assignment directory.

Notice the role of __init__ in the class CompareAndSwapSession. Read before Friday the Python tutorial on classes. (Note the lack of any mention of Java.)

Download the programs and run them though pylint3 (not pylint).

Writing a networked client program

Right now you have a server program. Testing it would be tedious. Write a Python program implementing a client program that connects to your server. Your client only need to send two or three requests to the server.

Start with a look at the Socket Programming HOWTO and the documentation for the socket interface. I suggest you start by invoking the Python3 interpreter and typing the relevant Python calls. You should be able to test your commands by connecting to the Compare And Swap server running on port 33333 on the Raspberry Pi computer pi3-d.cs.unca.edu .

If we have time, we’ll also look into writing a bash script. That will be much simpler. You will need to use here files.

Writing another networked client program

There is also a Fetch And Add server running on port 22222 of pi3-d.cs.unca.edu . Write a Python program to test out this server. Modify it to take arguments from the command line! You’ll need to use sys.argv to read the command line arguments.

It helps to be multilingual. Since we’ve all seen Java, let’s try it out. Start by looking at Java’s lesson on “All About Sockets”. You can use NetBeans if you wish (and if it is installed).

Modifying a networked server

Next write a program that implements the Fetch And Add by modifying the Compare And Swap server.

What to turn in

For now just keep the files in your directory.