/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* ---
*
- * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- * related information and legal notices. It is expected that any future
- * projects/authors will amend these files as needed.
+ * See files README, COPYING and CREDITS in the root of the source
+ * tree for related information and legal notices. It is expected
+ * that future projects/authors will amend these files as needed.
*
* ---
*
* host.c: make stream connection to empire
- *
+ *
* Known contributors to this file:
* Dave Pare, 1989
* Steve McClure, 1998
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#ifndef _WIN32
-#include <arpa/inet.h>
+#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#else
-#include <io.h>
-#include <winsock.h>
+#define close(fd) w32_close_socket((fd))
#endif
#include "misc.h"
if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0)
break; /* success */
-
close(sockfd); /* ignore this one */
} while ((res = res->ai_next) != NULL);
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
-#ifdef _WIN32
- errno = WSAGetLastError();
-#endif
return -1;
}
addr->sin_family = AF_INET;
if (connect(s, (struct sockaddr *)addr, sizeof(*addr)) < 0) {
-#ifdef _WIN32
- errno = WSAGetLastError();
-#endif
(void)close(s);
return -1;
}