implementation recepetion message incomplete et makefile foncitonne avec deux headers separes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "../includes/minitalk.h"
|
||||
#include "client.h"
|
||||
|
||||
int usage(void)
|
||||
{
|
||||
@@ -13,12 +13,15 @@ void send_char(int server_pid, char c)
|
||||
mask = 1 << 6;
|
||||
while (mask != 0)
|
||||
{
|
||||
if ((c & mask) != 0)
|
||||
kill(server_pid, SIGUSR1);
|
||||
if ((c & mask) == 0)
|
||||
kill(server_pid, SIGUSR2);
|
||||
mask >>= 1;
|
||||
usleep(1);
|
||||
if (msg_received == 1)
|
||||
{
|
||||
if ((c & mask) != 0)
|
||||
kill(server_pid, SIGUSR1);
|
||||
if ((c & mask) == 0)
|
||||
kill(server_pid, SIGUSR2);
|
||||
msg_received = 0;
|
||||
mask >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +35,19 @@ void send_message(int server_pid, char *msg)
|
||||
send_char(server_pid, *msg);
|
||||
}
|
||||
|
||||
void message_received(int sig_num)
|
||||
{
|
||||
(void)sig_num;
|
||||
msg_received = 1;
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
signal(SIGUSR1, message_received);
|
||||
if (ac != 3)
|
||||
return (usage());
|
||||
send_message(ft_atoi(av[1]), av[2]);
|
||||
msg_received = 1;
|
||||
ft_putnbrendl((int)getpid());
|
||||
send_message(ft_atoi(av[1]), av[2]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user