diff --git a/README.md b/README.md index 39af52c..5b74c60 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,25 @@ -# README # +# MINITALK -This README would normally document whatever steps are necessary to get your application up and running. +### how to use : -### What is this repository for? ### +first launch server : +``` +./server +``` +it will print a line with its own pid, and an empty line below +if you want to terminate the program hit `ctrl-c` -* Quick summary -* Version -* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo) +then in another window launch the client, with two arguments : +``` +./client [SERVER PID] [string] +``` +[SERVER PID] is the pid number printed by the server +[string] is whatever you want to write, surrounded by `"` if you want to include spaces : `"a random phrase"` -### How do I get set up? ### +### ressources -* Summary of set up -* Configuration -* Dependencies -* Database configuration -* How to run tests -* Deployment instructions - -### Contribution guidelines ### - -* Writing tests -* Code review -* Other guidelines - -### Who do I talk to? ### - -* Repo owner or admin -* Other community or team contact \ No newline at end of file +- **use of getpid** : https://www.includehelp.com/c/getpid-and-getppid-functions-in-c-linux.aspx +- **use of signal** : https://linuxhint.com/signal_handlers_c_programming_language +- **use of sigaction** : https://stackoverflow.com/a/17572787/9497573 +- **standard signal vs real time signals (with queue option)** : https://www.softprayog.in/programming/posix-real-time-signals-in-linux +- **test time of functions in program** : https://stackoverflow.com/a/5833240/9497573 diff --git a/builds/client.o b/builds/client.o index c0a3059..5a8902d 100644 Binary files a/builds/client.o and b/builds/client.o differ diff --git a/builds/server.o b/builds/server.o index 15218d6..7664bf4 100644 Binary files a/builds/server.o and b/builds/server.o differ diff --git a/client b/client index 09cf9db..8897c41 100755 Binary files a/client and b/client differ diff --git a/server b/server index 3bafd18..47f8cc3 100755 Binary files a/server and b/server differ diff --git a/srcs/client.c b/srcs/client.c index d80caf8..85a543c 100644 --- a/srcs/client.c +++ b/srcs/client.c @@ -27,7 +27,6 @@ void send_message(int sig_num) } if (client.done == 0) send_char(client.text[client.count_char], client.mask, client.srv_pid); - ft_putnbrbase(client.text[client.count_char], "01"); ft_printf(" - %i - [%i] %s\n", (client.text[client.count_char] & client.mask) != 0, client.count_char, client.text + client.count_char); } void init_client(int pid, char *msg) @@ -46,6 +45,7 @@ int main(int ac, char **av) return (usage()); init_client(ft_atoi(av[1]), av[2]); kill((int)getpid(), SIGUSR1); - while (client.done == 0); + while (client.done == 0) + ; return (0); } diff --git a/srcs/server.c b/srcs/server.c index cfc1d73..ce9a575 100644 --- a/srcs/server.c +++ b/srcs/server.c @@ -5,8 +5,6 @@ void send_char(void) if (message.count_bits == 7) { ft_putchar(message.character); - if (message.character == '\0') - exit(EXIT_SUCCESS); message.count_bits = 0; message.character = 0; } @@ -38,10 +36,10 @@ void init_message(void) message.text = ft_strdup(""); } -int main() +int main(void) { - struct sigaction act_1; - struct sigaction act_2; + struct sigaction act_1; + struct sigaction act_2; act_1.sa_flags = SA_SIGINFO; act_1.sa_sigaction = sig_handler_1; @@ -51,7 +49,8 @@ int main() sigaction(SIGUSR2, &act_2, NULL); ft_putnbrendl((int)getpid()); init_message(); - while (1); + while (1) + ; return (0); } @@ -105,7 +104,7 @@ int main() ** # # # # # # # # # # # # # # # # # # # # ** CODE TO CALCULATE TIME IN MICROSECONDS ** -** found here https://stackoverflow.com/questions/5833094/get-a-timestamp-in-c-in-microseconds +** found here : https://stackoverflow.com/a/5833240/9497573 ** ** #include ** #include