aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/emacsclient.c
diff options
context:
space:
mode:
authorMiles Bader <[email protected]>2007-10-27 09:07:17 +0000
committerMiles Bader <[email protected]>2007-10-27 09:07:17 +0000
commitfdc9061358d3654e14bfc1419632e1d6c6c5c13e (patch)
tree00f5484d576513deddd938a9a277d0db860b9a5b /lib-src/emacsclient.c
parentebe4c71027cd6ec8583631e895e7fdd3decfc099 (diff)
parentb6ff295c434269fe824ec47cbfc87c6a02dfd94d (diff)
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: [email protected]/emacs--devo--0--patch-908
Diffstat (limited to 'lib-src/emacsclient.c')
-rw-r--r--lib-src/emacsclient.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index a48a33f68b..99e0dc3ce3 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;
}