2 * Copyright (C) 1995-2005 The Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 /* startserver.c --- open a connection to the CVS server under Windows NT
16 Jim Blandy <jimb@cyclic.com> --- August 1995 */
22 #include <sys/socket.h>
27 /* Keep track of whether we've opened a socket so that wnt_shutdown_server
28 can do the correct thing. We don't want to call shutdown or
29 closesocket on a pipe. */
31 static int opened_a_socket = 0;
34 wnt_start_server (int *tofd, int *fromfd,
47 if (! (cvs_server = getenv ("CVS_SERVER")))
49 command = xmalloc (strlen (cvs_server)
50 + strlen (server_cvsroot)
52 sprintf (command, "%s -d %s server", cvs_server, server_cvsroot);
54 portenv = getenv("CVS_RCMD_PORT");
57 else if ((sptr = getservbyname("shell", "tcp")) != NULL)
60 port = IPPORT_CMDSERVER; /* shell/tcp */
62 read_fd = rcmd (&server_host,
65 (server_user ? server_user : client_user),
69 error (1, 0, "cannot start server via rcmd: %s",
70 SOCK_STRERROR (SOCK_ERRNO));
81 wnt_shutdown_server (int fd)
88 if (shutdown (s, 2) == SOCKET_ERROR)
89 error (1, 0, "couldn't shutdown server connection: %s",
90 SOCK_STRERROR (SOCK_ERRNO));
91 if (closesocket (s) == SOCKET_ERROR)
92 error (1, 0, "couldn't close server connection: %s",
93 SOCK_STRERROR (SOCK_ERRNO));
98 error (1, errno, "cannot close server connection");