OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Request.h" | 8 #include "Request.h" |
9 #include "Response.h" | 9 #include "Response.h" |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 Request request(SkString("/data")); // This simple server has one request | 80 Request request(SkString("/data")); // This simple server has one request |
81 | 81 |
82 struct sockaddr_in address; | 82 struct sockaddr_in address; |
83 address.sin_family = AF_INET; | 83 address.sin_family = AF_INET; |
84 address.sin_port = htons(FLAGS_port); | 84 address.sin_port = htons(FLAGS_port); |
85 inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); | 85 inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); |
86 | 86 |
87 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port ); | 87 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port ); |
88 | 88 |
89 struct MHD_Daemon* daemon; | 89 struct MHD_Daemon* daemon; |
90 // TODO Add option to bind this strictly to an address, e.g. localhost, for security. | 90 // TODO Add option to bind this strictly to an address, e.g. localhost, for security. |
jcgregorio
2016/03/04 16:06:18
The TODO can be removed, that's what the --address
| |
91 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, FLAGS_port, nullptr, nu llptr, | 91 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY |
92 #ifdef SK_DEBUG | |
93 | MHD_USE_DEBUG | |
94 #endif | |
95 , FLAGS_port, nullptr, nullptr, | |
92 &answer_to_connection, &request, | 96 &answer_to_connection, &request, |
93 MHD_OPTION_SOCK_ADDR, &address, | 97 MHD_OPTION_SOCK_ADDR, &address, |
94 MHD_OPTION_END); | 98 MHD_OPTION_END); |
95 if (NULL == daemon) { | 99 if (NULL == daemon) { |
100 SkDebugf("Could not initialize daemon\n"); | |
96 return 1; | 101 return 1; |
97 } | 102 } |
98 | 103 |
99 getchar(); | 104 getchar(); |
100 MHD_stop_daemon(daemon); | 105 MHD_stop_daemon(daemon); |
101 return 0; | 106 return 0; |
102 } | 107 } |
103 | 108 |
104 #if !defined SK_BUILD_FOR_IOS | 109 #if !defined SK_BUILD_FOR_IOS |
105 int main(int argc, char** argv) { | 110 int main(int argc, char** argv) { |
106 SkCommandLineFlags::Parse(argc, argv); | 111 SkCommandLineFlags::Parse(argc, argv); |
107 return skiaserve_main(); | 112 return skiaserve_main(); |
108 } | 113 } |
109 #endif | 114 #endif |
OLD | NEW |