diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2022-09-09 11:19:21 +0200 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2022-09-09 11:20:33 +0200 |
commit | c6d8db8d91649d4e30bb26c662ac867136005c0c (patch) | |
tree | 583431c29e88648fdc1f3e140319ac9668c445d7 | |
parent | a0886b321c4792ac52d69900a999840c7ee1d90a (diff) | |
download | emacs-c6d8db8d91649d4e30bb26c662ac867136005c0c.tar.gz |
Display error in emacsclient if setsockopt failed
* lib-src/emacsclient.c (set_tcp_socket, set_socket_timeout): Display
an error message if setsockopt failed.
-rw-r--r-- | lib-src/emacsclient.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 49d90a989fc..88800b9b2e9 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1078,7 +1078,9 @@ set_tcp_socket (const char *local_server_file) /* The cast to 'const char *' is to avoid a compiler warning when compiling for MS-Windows sockets. */ - setsockopt (s, SOL_SOCKET, SO_LINGER, (const char *) &l_arg, sizeof l_arg); + int ret = setsockopt (s, SOL_SOCKET, SO_LINGER, (const char *) &l_arg, sizeof l_arg); + if (ret < 0) + sock_err_message ("setsockopt"); /* Send the authentication. */ auth_string[AUTH_KEY_LENGTH] = '\0'; @@ -1892,11 +1894,13 @@ start_daemon_and_retry_set_socket (void) static void set_socket_timeout (HSOCKET socket, int seconds) { + int ret; + #ifndef WINDOWSNT struct timeval timeout; timeout.tv_sec = seconds; timeout.tv_usec = 0; - setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout); + ret = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout); #else DWORD timeout; @@ -1904,8 +1908,11 @@ set_socket_timeout (HSOCKET socket, int seconds) timeout = INT_MAX; else timeout = seconds * 1000; - setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof timeout); + ret = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &timeout, sizeof timeout); #endif + + if (ret < 0) + sock_err_message ("setsockopt"); } static bool |