Mercurial > emacs
comparison lib-src/emacsclient.c @ 85688:b210bba3f477
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
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 27 Oct 2007 09:07:17 +0000 |
parents | a927843fe12d 7970215aa6e5 |
children | 153740aec87c 4bc33ffdda1a |
comparison
equal
deleted
inserted
replaced
85687:666ace46440f | 85688:b210bba3f477 |
---|---|
664 char send_buffer[SEND_BUFFER_SIZE + 1]; | 664 char send_buffer[SEND_BUFFER_SIZE + 1]; |
665 int sblen = 0; /* Fill pointer for the send buffer. */ | 665 int sblen = 0; /* Fill pointer for the send buffer. */ |
666 /* Socket used to communicate with the Emacs server process. */ | 666 /* Socket used to communicate with the Emacs server process. */ |
667 HSOCKET emacs_socket = 0; | 667 HSOCKET emacs_socket = 0; |
668 | 668 |
669 /* On Windows, the socket library was historically separate from the standard | |
670 C library, so errors are handled differently. */ | |
671 void | |
672 sock_err_message (function_name) | |
673 char *function_name; | |
674 { | |
675 #ifdef WINDOWSNT | |
676 char* msg = NULL; | |
677 | |
678 FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | |
679 | FORMAT_MESSAGE_ALLOCATE_BUFFER | |
680 | FORMAT_MESSAGE_ARGUMENT_ARRAY, | |
681 NULL, WSAGetLastError (), 0, (LPTSTR)&msg, 0, NULL); | |
682 | |
683 message (TRUE, "%s: %s: %s\n", progname, function_name, msg); | |
684 | |
685 LocalFree (msg); | |
686 #else | |
687 message (TRUE, "%s: %s: %s\n", progname, function_name, strerror (errno)); | |
688 #endif | |
689 } | |
690 | |
691 | |
669 /* Let's send the data to Emacs when either | 692 /* Let's send the data to Emacs when either |
670 - the data ends in "\n", or | 693 - the data ends in "\n", or |
671 - the buffer is full (but this shouldn't happen) | 694 - the buffer is full (but this shouldn't happen) |
672 Otherwise, we just accumulate it. */ | 695 Otherwise, we just accumulate it. */ |
673 void | 696 void |
955 /* | 978 /* |
956 * Open up an AF_INET socket | 979 * Open up an AF_INET socket |
957 */ | 980 */ |
958 if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) | 981 if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) |
959 { | 982 { |
960 message (TRUE, "%s: socket: %s\n", progname, strerror (errno)); | 983 sock_err_message ("socket"); |
961 return INVALID_SOCKET; | 984 return INVALID_SOCKET; |
962 } | 985 } |
963 | 986 |
964 /* | 987 /* |
965 * Set up the socket | 988 * Set up the socket |
966 */ | 989 */ |
967 if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) | 990 if (connect (s, (struct sockaddr *) &server, sizeof server) < 0) |
968 { | 991 { |
969 message (TRUE, "%s: connect: %s\n", progname, strerror (errno)); | 992 sock_err_message ("connect"); |
970 return INVALID_SOCKET; | 993 return INVALID_SOCKET; |
971 } | 994 } |
972 | 995 |
973 setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg); | 996 setsockopt (s, SOL_SOCKET, SO_LINGER, (char *) &l_arg, sizeof l_arg); |
974 | 997 |