Annotation of libaitio/example/sendfile.c, revision 1.3
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:
19: sin.sin_len = sizeof sin;
20: sin.sin_family = AF_INET;
21: sin.sin_port = htons(5000);
22: sin.sin_addr.s_addr = inet_addr("127.0.0.1");
23:
24: s = socket(AF_INET, SOCK_STREAM, 0);
25: if (s == -1) {
26: perror("socket");
27: return 2;
28: }
29: if (connect(s, (struct sockaddr*) &sin, sizeof sin) == -1) {
30: perror("connect");
31: close(s);
32: return 3;
33: }
34:
35: sl = ioSendFile(s, argv[1], 0, 0, argv[3] ? strtol(argv[3], NULL, 0) : 0);
36: printf("sended %d bytes\n", sl);
37: if (!sl)
38: printf("#%d - %s\n", io_GetErrno(), io_GetError());
39:
40: close(s);
41: return 0;
42: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>