Skip to content

i5-650/client-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

client-server

Client-server project for school. We recommand you to read the full README.md file before running or compiling the code.

What's possible now ?

  • Send a message to the server and receive it back
  • Send your name or a choosen name to the server and receive it back
  • Send an array of colors to the server and have it saved
  • Send the informations about an image and save those informations on the server.
  • Send multiple tags, up to 30, to the server and have them saved
  • The server can handle multiple clients at the same time, up to 9 for now.
  • Somes operations are possible such as: addition, substraction, division, multiplication, minimun, maximum, average and variance.
  • The server handle client disconnections and disappearances.
  • The clients handle interruptions, it means that if you ctrl-c on the client: it sends a message to the server to inform it that the client is disconnected and the server will handle it.
  • Clients and Server communicate with JSON messages.

The JSON messages

The JSON messages are following a specific format for not single textual informations.

{
    "code": "msg", // the code is always on exactly 3 characters without capital letters
    "values": [3, 1, 2, 3] // the values are always in an array. The first value MUST be the number of values that will be sent. The only exception is the 'cal' code. 
}

If the message is a single text information, the value array will only contain one value: the string sent/received.

Examples

{
    "code": "okk",
    "values": ["Something saying everything is okay"]
}
{
    "code": "err",
    "values": ["Something saying everything what happened"]
}
{
    "code": "msg",
    "values": ["Hello World"]
}
{
    "code": "nam",
    "values": ["hostname"]
}
{
    "code": "col",
    "values": [4, "0xffffff", "0xffffff", "0xffffff", "0xffffff"]
}
{
    "code": "anl",
    "values": [4, "0xffffff", "0xffffff", "0xffffff", "0xffffff"]
}
{
    "code": "min",
    "values": [4, 10, 11, 12, 13]
}
{
    "code": "max",
    "values": [4, 10, 11, 12, 13]
}
{
    "code": "avg",
    "values": [4, 10, 11, 12, 13]
}
{
    "code": "ect",
    "values": [4, 10, 11, 12, 13]
}
{
    "code": "tag",
    "values": [3, "tag1", "tag2", "tag3"]
}

The exception

{
    "code": "CAL",
    "values": ["+", 2.14, 3] // the first value is the operator. The second and third values are the numbers to operate on.
}

Mac and Linux difference

If you are willing to run this code on MacOs, it will work fine. We encountered a problem using semaphores on Mac. Indeed, Mac doesn't support a non-deprecated version of posix semaphores. So we had to use an other version of it, specific to mac. Do not worry, if you run this code on Linux it will use the posix semaphores.

Compilation goals

There is 3 compilation goals:

  • make all, make, make -j... That will compile the server and the client with debug options. If you just want to try the code, use this one.
  • make testes: This goal will compile every .c files and remove the main function from client.c and serveur.c to make the code testable. It will also compile the tests files. If you want to unitary test the code, use this one.
  • make release: This goal will compile the server and the client without debug options. If you want to run the code on a server, use this one. There is no tests in this goal and flags to make the code faster.

Running and usefull goals

  • make tests will run the tests. If you want to run the tests, use this one.
  • make clean will remove all the .o, .out and .txt files in the project.

Releases

No releases published

Packages

No packages published