emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lib-src/emacsclient.c, v [EMACS_22_BASE]


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/lib-src/emacsclient.c, v [EMACS_22_BASE]
Date: Thu, 25 Oct 2007 23:56:34 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Branch:         EMACS_22_BASE
Changes by:     Jason Rumney <jasonr>   07/10/25 23:56:34

Index: emacsclient.c
===================================================================
RCS file: /sources/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.104.2.2
retrieving revision 1.104.2.3
diff -u -b -r1.104.2.2 -r1.104.2.3
--- emacsclient.c       27 Sep 2007 22:08:35 -0000      1.104.2.2
+++ emacsclient.c       25 Oct 2007 23:56:34 -0000      1.104.2.3
@@ -395,6 +395,29 @@
 char send_buffer[SEND_BUFFER_SIZE + 1];
 int sblen = 0; /* Fill pointer for the send buffer.  */
 
+/* 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)
@@ -646,7 +669,7 @@
    */
   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;
     }
 
@@ -655,7 +678,7 @@
    */
   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;
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]