This project may be used to set up a development for client-service applications using Linux Operating System and the project shows a simple client-server application using sockets in the C programming language. The server listens to TCP connections at a socket and then serves either requests for local text files or accepts a message from the client. The server may only terminate when the user enters CTRL + C.
Start a Terminal/PowerShell and enter:
docker compose run --rm --name server server
Start another Terminal/PowerShell and enter:
docker compose run --rm --name client1 client
Each client requires to use a different container name, i.e., change client1 to client2, client3, etc.
The sample application is in client-server directory. You may compile the programs on either the Ubuntu server machine or an Ubuntu client machine.
cd client-server
gcc -o server server.c server-helper.c
gcc -o client client.c client-helper.c
In the client-server directory on the Ubuntu server machine, enter:
./server server 41000
You may use any non-privileged port for the applciation server to listen to.
In the client-server directory on an Ubunto client machine, enter
./client server 41000 server-helper.h
server: container name of the Ubuntu server. The name is defined in compose.yaml.
41000: port the application server listens to.
server-helper.h: a file in the current directory. It can be any file in the directory
Click the following link to download, install, configure the app.
Click the Applications tab and then press CSAWS Student VPN Portal. Download the VPN client app for your OS and download the configuration file.
After installing the VPN client app, you need to create a Profile and find and use the configuration file you just downloaded.
Run the AWS VPN client and connect to the VPN
In a Terminal/PowerShell, enter the following. Replace the names with your real name.
ssh yourfirstname-yourlastname@172.30.129.135
exit
This step is to copy all the C code file for the app server to the remote FreeBSD machine.
In a Terminal/PowerShell, enter the following. Replace the names with your real name.
scp client-server/server* yourfirstname-yourlastname@172.30.129.135:/usr/home/yourfirstname-yourlastname/.
In a Terminal/PowerShell, enter the following. Replace the names with your real name.
ssh yourfirstname-yourlastname@172.30.129.135
After logged into the FreeBSD machine, enter the following to compile and run the app server:
cd client-server
gcc -o server server.c server-helper.c
./server 172.30.129.135 41000
Start another Terminal/PowerShell on your local machine, enter:
docker compose run --rm --name remoteclient1 remoteclient
In the Ubuntu machine, enter the following to start the client:
cd client-server
gcc -o client client.c client-helper.c
./client 172.30.129.135 41000 server-helper.h
You can test the sample app by enter 1, 2, 0 to request the server to return server-helper.h file and send a "Hello World" message to the server. Option 0 is to stop the client.
Kill the app server by pressing CTRL + c, and then enter the following to exit the FreeBSD machine.
exit
Your VPN connection incurs cost ($$$$) to the University. so please DISCONNECT the VPN once it is no longer needed.