diff options
author | Miles Bader <miles@gnu.org> | 2007-10-27 09:07:17 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2007-10-27 09:07:17 +0000 |
commit | fdc9061358d3654e14bfc1419632e1d6c6c5c13e (patch) | |
tree | 00f5484d576513deddd938a9a277d0db860b9a5b /lib-src/emacsclient.c | |
parent | ebe4c71027cd6ec8583631e895e7fdd3decfc099 (diff) | |
parent | b6ff295c434269fe824ec47cbfc87c6a02dfd94d (diff) | |
download | emacs-fdc9061358d3654e14bfc1419632e1d6c6c5c13e.tar.gz |
Merge from emacs--rel--22
Patches applied:
* emacs--rel--22 (patch 131-137)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 261-262)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-908
Diffstat (limited to 'lib-src/emacsclient.c')
-rw-r--r-- | lib-src/emacsclient.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index a48a33f68b8..99e0dc3ce3d 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -666,6 +666,29 @@ int sblen = 0; /* Fill pointer for the send buffer. */ /* Socket used to communicate with the Emacs server process. */ HSOCKET emacs_socket = 0; +/* On Windows, the socket library was historically separate from the standard + C library, so errors are handled differently. */ +void +sock_err_message (function_name) + char *function_name; +{ +#ifdef WINDOWSNT + char* msg = NULL; + + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_ARGUMENT_ARRAY, + NULL, WSAGetLastError (), 0, (LPTSTR)&msg, 0, NULL); + + message (TRUE, "%s: %s: %s\n", progname, function_name, msg); + + LocalFree (msg); +#else + message (TRUE, "%s: %s: %s\n", progname, function_name, strerror (errno)); +#endif +} + + /* Let's send the data to Emacs when either - the data ends in "\n", or - the buffer is full (but this shouldn't happen) @@ -957,7 +980,7 @@ set_tcp_socket () */ if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - message (TRUE, "%s: socket: %s\n", progname, strerror (errno)); + sock_err_message ("socket"); return INVALID_SOCKET; } @@ -966,7 +989,7 @@ set_tcp_socket () */ if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) { - message (TRUE, "%s: connect: %s\n", progname, strerror (errno)); + sock_err_message ("connect"); return INVALID_SOCKET; } |