blob: 60d2f1f0db9dec5b28c431b67c6578e0259a698b (
plain)
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
|
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
static char buffer[1024 * 1024];
int main(void)
{
struct sockaddr_in sa;
size_t count = 0;
size_t size;
int rv;
int s;
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s < 0)
return 1;
memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = inet_addr("127.0.0.1");
sa.sin_port = htons(8806);
if (connect(s, (struct sockaddr *)&sa, sizeof(struct sockaddr)) != 0)
return 1;
printf("send (%d): type message and hit RETURN to send signal\n",
getpid());
fgets(buffer, sizeof(buffer), stdin);
/* set "sending" uprobe here */
size = strlen(buffer);
if (write(s, &size, sizeof(size)) != sizeof(size))
return 1;
while (count < size) {
rv = write(s, buffer + count, size - count);
if (rv <= 0)
return 1;
count += rv;
}
sleep(1);
return 0;
}
|