File:
[ELWIX - Embedded LightWeight unIX -] /
libaitio /
example /
sendfile.c
Revision
1.3:
download - view:
text,
annotated -
select for diffs -
revision graph
Wed Jun 26 22:48:53 2013 UTC (11 years, 1 month ago) by
misho
Branches:
MAIN
CVS tags:
io7_3,
io7_2,
io7_1,
io7_0,
io6_9,
io6_8,
io6_7,
io6_6,
io6_5,
io6_4,
io6_3,
io6_2,
io6_1,
io6_0,
io5_9,
io5_8,
io5_7,
io5_6,
io5_5,
IO7_2,
IO7_1,
IO7_0,
IO6_9,
IO6_8,
IO6_7,
IO6_6,
IO6_5,
IO6_4,
IO6_3,
IO6_2,
IO6_1,
IO6_0,
IO5_9,
IO5_8,
IO5_7,
IO5_6,
IO5_5,
IO5_4,
HEAD
version 5.4
1: #include <stdio.h>
2: #include <unistd.h>
3: #include <sys/types.h>
4: #include <sys/socket.h>
5: #include <netinet/in.h>
6: #include <arpa/inet.h>
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>