| 174 | #endif |
| 175 | |
| 176 | int |
| 177 | main(int argc, char **argv) |
| 178 | { |
| 179 | GSocketService *service = g_threaded_socket_service_new(-1); |
| 180 | g_signal_connect(service, "event", G_CALLBACK(service_event), NULL); |
| 181 | g_signal_connect(service, "incoming", G_CALLBACK(service_incoming), NULL); |
| 182 | |
| 183 | GError *error = NULL; |
| 184 | gboolean success = |
| 185 | g_socket_listener_add_any_inet_port(G_SOCKET_LISTENER(service), NULL, &error); |
| 186 | if (!success) { |
| 187 | g_print("failed to add a listen IP address: %s\n", error->message); |
| 188 | g_error_free(error); |
| 189 | return EXIT_FAILURE; |
| 190 | } |
| 191 | |
| 192 | g_socket_service_start(service); |
| 193 | |
| 194 | GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
| 195 | #ifdef G_OS_UNIX |
| 196 | StopData data; |
| 197 | data.service = service; |
| 198 | data.loop = loop; |
| 199 | g_unix_signal_add(SIGINT, stop, &data); |
| 200 | g_unix_signal_add(SIGTERM, stop, &data); |
| 201 | #else |
| 202 | /* TODO: Implement graceful stop. */ |
| 203 | #endif |
| 204 | g_main_loop_run(loop); |
| 205 | g_main_loop_unref(loop); |
| 206 | |
| 207 | return EXIT_SUCCESS; |
| 208 | } |
nothing calls this directly
no outgoing calls
no test coverage detected