Annotation of libaitio/example/sendfile.c, revision 1.4
1.2 misho 1: #include <stdio.h>
1.3 misho 2: #include <unistd.h>
1.2 misho 3: #include <sys/types.h>
4: #include <sys/socket.h>
5: #include <netinet/in.h>
1.3 misho 6: #include <arpa/inet.h>
1.2 misho 7: #include <aitio.h>
8:
9:
10: int
11: main(int argc, char **argv)
12: {
13: int s, sl;
14: struct sockaddr_in sin;
15:
16: if (argc < 3)
17: return 1;
18:
1.4 ! misho 19: #ifndef __linux__
1.2 misho 20: sin.sin_len = sizeof sin;
1.4 ! misho 21: #endif
1.2 misho 22: sin.sin_family = AF_INET;
23: sin.sin_port = htons(5000);
24: sin.sin_addr.s_addr = inet_addr("127.0.0.1");
25:
26: s = socket(AF_INET, SOCK_STREAM, 0);
27: if (s == -1) {
28: perror("socket");
29: return 2;
30: }
31: if (connect(s, (struct sockaddr*) &sin, sizeof sin) == -1) {
32: perror("connect");
33: close(s);
34: return 3;
35: }
36:
37: sl = ioSendFile(s, argv[1], 0, 0, argv[3] ? strtol(argv[3], NULL, 0) : 0);
38: printf("sended %d bytes\n", sl);
39: if (!sl)
40: printf("#%d - %s\n", io_GetErrno(), io_GetError());
41:
42: close(s);
43: return 0;
44: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>