diff --git a/src/sf_service.c b/src/sf_service.c index d74ebf6..e844ac1 100644 --- a/src/sf_service.c +++ b/src/sf_service.c @@ -400,6 +400,19 @@ int sf_socket_server_ex(SFContext *sf_context) return 0; } +void sf_socket_close_ex(SFContext *sf_context) +{ + if (sf_context->inner_sock >= 0) { + close(sf_context->inner_sock); + sf_context->inner_sock = -1; + } + + if (sf_context->outer_sock >= 0) { + close(sf_context->outer_sock); + sf_context->outer_sock = -1; + } +} + static void accept_run(struct accept_thread_context *accept_context) { int incomesock; diff --git a/src/sf_service.h b/src/sf_service.h index a49bd97..8008485 100644 --- a/src/sf_service.h +++ b/src/sf_service.h @@ -86,6 +86,9 @@ void sf_set_current_time(); int sf_socket_server_ex(SFContext *sf_context); #define sf_socket_server() sf_socket_server_ex(&g_sf_context) +void sf_socket_close_ex(SFContext *sf_context); +#define sf_socket_close() sf_socket_close_ex(&g_sf_context) + void sf_accept_loop_ex(SFContext *sf_context, const bool block); #define sf_accept_loop() sf_accept_loop_ex(&g_sf_context, true)