Here are the steps for installation process of client-server app written in c
- Installing PostgreSQL Database
- Configuring PostgreSQL
- Linking libpq libraries for PostgreSQL in C
First we will start with installing PostgreSQL
Open terminal:
sudo apt install postgresql-9.6 postgresql-client-9.6 postgresql-client-common libpq-dev postgresql-common postgresql-contrib-9.6 postgresql-server-dev-9.6 postgresql-doc-9.6
After installation, execute following commands in terminal
sudo su postgres
psql
CREATE DATABASE "OCTS";
CREATE USER octs WITH PASSWORD 'OCTSIUTOSPROJECT2017';
ALTER USER octs WITH SUPERUSER;
Open the project source directory and you will see cmake file
CMakeLists.txt
. Build this file with cmake, if you are using CLion,
then open CMake
tool window and click Reload CMake Project
When you are executing server application first time, call run_migrations()
function to create all table relations of the project.
Also if you look inside CMakeLists.txt
file, there are two executable files for client and server execution, so if you configure running configuration correctly, you can run both client-server inside one project.
If you want to better manipulate your database instances, install DataGrip by JetBrains.
char *token;
token=generate_token();
- Send message
struct Client *file_client = new(Client, FILE_SERVER_LISTEN_PORT);
cJSON *params = cJSON_CreateObject();
//Add values to params json object
cJSON *response = (cJSON *) send_message(client, method_id, params);
- Send file
struct Server *file_server = new(Server, FILE_SERVER_LISTEN_PORT);
cJSON *response = (cJSON *) send_file(file_client,
"/Users/tom1/Documents/Subject files/OS/Project/octs/client/client/client.c",
"client.c");