Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a duk_trans_socket_active() function to allow application #2366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/debug-trans-socket/duk_trans_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 5 additions & 0 deletions examples/debug-trans-socket/duk_trans_socket_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions examples/debug-trans-socket/duk_trans_socket_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down