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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 int skiaserve_main() { | 81 int skiaserve_main() { |
82 Request request(SkString("/data")); // This simple server has one request | 82 Request request(SkString("/data")); // This simple server has one request |
83 | 83 |
84 struct sockaddr_in address; | 84 struct sockaddr_in address; |
85 address.sin_family = AF_INET; | 85 address.sin_family = AF_INET; |
86 address.sin_port = htons(FLAGS_port); | 86 address.sin_port = htons(FLAGS_port); |
87 int result = inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); | 87 int result = inet_pton(AF_INET, FLAGS_address[0], &address.sin_addr); |
88 if (result != 1) { | 88 if (result != 1) { |
89 printf("inet_pton for %s:%d failed with return %d %s\n", | 89 printf("inet_pton for %s:%d failed with return %d %s\n", |
90 FLAGS_address[0], FLAGS_port, result, strerror(errno)); | 90 FLAGS_address[0], FLAGS_port, result, strerror(errno)); |
91 return 1; | 91 return 1; |
92 } | 92 } |
93 | 93 |
94 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port
); | 94 printf("Visit http://%s:%d in your browser.\n", FLAGS_address[0], FLAGS_port
); |
95 | 95 |
96 struct MHD_Daemon* daemon; | 96 struct MHD_Daemon* daemon; |
97 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | 97 daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY |
98 #ifdef SK_DEBUG | 98 #ifdef SK_DEBUG |
99 | MHD_USE_DEBUG | 99 | MHD_USE_DEBUG |
100 #endif | 100 #endif |
101 , FLAGS_port, nullptr, nullptr, | 101 , FLAGS_port, nullptr, nullptr, |
102 &answer_to_connection, &request, | 102 &answer_to_connection, &request, |
103 MHD_OPTION_SOCK_ADDR, &address, | 103 MHD_OPTION_SOCK_ADDR, &address, |
104 MHD_OPTION_END); | 104 MHD_OPTION_END); |
105 if (NULL == daemon) { | 105 if (NULL == daemon) { |
106 SkDebugf("Could not initialize daemon\n"); | 106 SkDebugf("Could not initialize daemon\n"); |
107 return 1; | 107 return 1; |
108 } | 108 } |
109 | 109 |
110 getchar(); | 110 getchar(); |
111 MHD_stop_daemon(daemon); | 111 MHD_stop_daemon(daemon); |
112 return 0; | 112 return 0; |
113 } | 113 } |
114 | 114 |
115 #if !defined SK_BUILD_FOR_IOS | 115 #if !defined SK_BUILD_FOR_IOS |
116 int main(int argc, char** argv) { | 116 int main(int argc, char** argv) { |
117 SkCommandLineFlags::Parse(argc, argv); | 117 SkCommandLineFlags::Parse(argc, argv); |
118 return skiaserve_main(); | 118 return skiaserve_main(); |
119 } | 119 } |
120 #endif | 120 #endif |
OLD | NEW |