-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.c
53 lines (48 loc) · 1.41 KB
/
client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vismaily <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/27 18:53:21 by vismaily #+# #+# */
/* Updated: 2022/06/05 16:11:13 by vismaily ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <signal.h>
#include "libft.h"
void send_bit_by_bit(int pid, char *argv)
{
size_t len;
size_t i;
int shift;
len = ft_strlen(argv);
i = 0;
while (i < len)
{
shift = 0;
while (shift < 8)
{
if ((argv[i] >> shift) & 1)
kill(pid, SIGUSR2);
else
kill(pid, SIGUSR1);
shift++;
usleep(100);
}
i++;
}
}
int main(int argc, char **argv)
{
pid_t pid;
if (argc == 3)
{
pid = ft_atoi(argv[1]);
send_bit_by_bit(pid, argv[2]);
}
else
write(1, "./client pid message\n", 21);
return (0);
}