Sync usage with man page.
[netbsd-mini2440.git] / sys / rump / librump / test / sysproxy / client / sysproxy_client.c
blobc32cdc113eb70d6d9ad95fe4b7b0b5661bcf970c
1 #include <sys/types.h>
2 #include <sys/socket.h>
3 #include <sys/stat.h>
4 #include <sys/time.h>
5 #include <sys/un.h>
7 #include <netinet/in.h>
8 #include <netinet/tcp.h>
10 #include <rump/rump.h>
11 #include <rump/rump_syscalls.h>
13 #include <errno.h>
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
18 #define SERVPATH "/tmp/rump_sysproxy_test"
19 #define USE_UN
21 int
22 main()
24 struct stat sb[3];
25 int s, error;
26 size_t len;
27 int i;
29 #ifdef USE_UN
30 struct sockaddr_un sun;
32 s = socket(AF_LOCAL, SOCK_STREAM, 0);
33 if (s == -1)
34 err(1, "socket");
36 memset(&sun, 0, sizeof(sun));
37 sun.sun_family = AF_LOCAL;
38 strcpy(sun.sun_path, SERVPATH);
39 if (connect(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) == -1)
40 err(1, "connect");
41 #else
42 struct sockaddr_in sin;
43 int x = 1;
45 s = socket(AF_INET, SOCK_STREAM, 0);
46 if (s == -1)
47 err(1, "socket");
49 memset(&sin, 0, sizeof(sin));
50 sin.sin_family = AF_INET;
51 sin.sin_port = htons(12345);
52 sin.sin_addr.s_addr = inet_addr("10.181.181.1");
53 if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) == -1)
54 err(1, "connect");
56 if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &x, sizeof(x)) == -1)
57 err(1, "setsockopt");
58 #endif
60 rump_init();
61 rump_sysproxy_socket_setup_client(s);
63 if (rump_sys_stat("/", &sb[1]) == -1)
64 err(1, "stat");