Browse Source

Add a duk_trans_socket_active() function to allow application to allow for graceful shutdown

pull/2366/head
benjymous 4 years ago
parent
commit
5d9e3d6b01
  1. 2
      examples/debug-trans-socket/duk_trans_socket.h
  2. 5
      examples/debug-trans-socket/duk_trans_socket_unix.c
  3. 5
      examples/debug-trans-socket/duk_trans_socket_windows.c

2
examples/debug-trans-socket/duk_trans_socket.h

@ -16,6 +16,8 @@ duk_size_t duk_trans_socket_peek_cb(void *udata);
void duk_trans_socket_read_flush_cb(void *udata);
void duk_trans_socket_write_flush_cb(void *udata);
duk_bool_t duk_trans_socket_active(void);
#if defined(__cplusplus)
}
#endif /* end 'extern "C"' wrapper */

5
examples/debug-trans-socket/duk_trans_socket_unix.c

@ -89,6 +89,11 @@ void duk_trans_socket_finish(void) {
}
}
duk_bool_t duk_trans_socket_active(void)
{
return server_sock >= 0;
}
void duk_trans_socket_waitconn(void) {
struct sockaddr_in addr;
socklen_t sz;

5
examples/debug-trans-socket/duk_trans_socket_windows.c

@ -167,6 +167,11 @@ void duk_trans_socket_finish(void) {
}
}
duk_bool_t duk_trans_socket_active(void)
{
return server_sock != INVALID_SOCKET;
}
void duk_trans_socket_waitconn(void) {
if (server_sock == INVALID_SOCKET) {
fprintf(stderr, "%s: no server socket, skip waiting for connection\n",

Loading…
Cancel
Save