* #include <sys/types.h>
* #include <sys/socket.h>
* #include <ccan/oserver/oserver.h>
+ * #include <ccan/opt/opt.h>
* #include <err.h>
* #include <stdlib.h>
*
- * int main(void)
+ * int main(int argc, char *argv[])
* {
- * int fd, sockfd;
+ * struct tevent_context *ev = tevent_context_init(NULL);
+ * unsigned int port = OSERVER_PORT;
*
- * sockfd = oserver_setup();
- * if (sockfd < 0)
- * err(1, "Failed to set up server socket");
+ * opt_register_noarg("--help|--usage|-h", opt_usage_and_exit,
+ * "\nA oserver program", "Usage information");
+ * opt_register_arg("--port", opt_set_uintval, opt_show_uintval,
+ * &port, "Server port number");
*
- * fd = accept(sockfd, NULL, NULL);
- * if (fd < 0)
- * err(1, "Accepting connection on TCP socket");
+ * opt_parse(&argc, argv, opt_log_stderr_exit);
+ * if (argc != 1)
+ * opt_log_stderr_exit("Unknown extra arguments");
*
- * if (!oserver_serve(fd))
- * err(1, "Serving client");
- * exit(0);
+ * if (!oserver_setup(ev, port))
+ * err(1, "Failed to set up server");
+ *
+ * while (tevent_loop_wait(ev) == 0);
+ * err(1, "Serving client");
* }
*/
int main(int argc, char *argv[])
printf("ccan/read_write_all\n");
printf("ccan/str\n");
printf("ccan/foreach\n");
- printf("ccan/noerr\n");
printf("ccan/failtest\n");
+ printf("ccan/opt\n");
+ printf("ccan/array_size\n");
+ printf("ccan/tevent\n");
return 0;
}