-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.c
49 lines (44 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jilai <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/28 15:11:28 by jilai #+# #+# */
/* Updated: 2024/04/28 15:11:31 by jilai ### ########.fr */
/* */
/* ************************************************************************** */
#include "client.h"
void send_char_bits(int pid, unsigned char ch)
{
int i;
unsigned char tmp;
i = 8;
tmp = ch;
while (i > 0)
{
i--;
tmp = ch >> i;
if (tmp % 2 == 0)
kill(pid, SIGUSR2);
else
kill(pid, SIGUSR1);
usleep(42);
}
}
int main(int argc, char *argv[])
{
int pid;
int i;
if (argc != 3)
exit(EXIT_FAILURE);
pid = atoi(argv[1]);
i = 0;
while (argv[2][i])
{
send_char_bits(pid, (unsigned char)(argv[2][i]));
i++;
}
return (0);
}