30#ifdef HAVE_NETINET_IN_H
31#include <netinet/in.h>
33#ifdef HAVE_ARPA_INET_H
42#ifdef HAVE_SYS_IOCTL_H
47#elif defined(HAVE_SYS_SIGNAL_H)
48#include <sys/signal.h>
50#ifdef FREECIV_MSWINDOWS
64#define INADDR_NONE 0xffffffff
67#ifdef HAVE_GETADDRINFO
69#define FC_AI_NUMERICSERV AI_NUMERICSERV
71#define FC_AI_NUMERICSERV 0
75#ifdef FREECIV_HAVE_WINSOCK
113#ifdef FREECIV_HAVE_WINSOCK
132#ifdef FREECIV_HAVE_WINSOCK
148#ifdef FREECIV_HAVE_WINSOCK
167#ifdef FREECIV_HAVE_WINSOCK
168 result = send(sock,
buf,
size, 0);
188#ifdef FREECIV_HAVE_WINSOCK
200#ifdef FREECIV_HAVE_WINSOCK
219#ifdef FREECIV_HAVE_WINSOCK
229#ifdef NONBLOCKING_SOCKETS
230#ifdef FREECIV_HAVE_WINSOCK
262 log_warn(
"NONBLOCKING_SOCKETS not available");
271#ifdef FREECIV_IPV6_SUPPORT
277 buf,
ntohs(addr->saddr_in6.sin6_port));
298 log_error(
"Unsupported address family in sockaddr_debug()");
307#ifdef FREECIV_MSWINDOWS
308 return sizeof(*addr);
310#ifdef FREECIV_IPV6_SUPPORT
312 return sizeof(addr->saddr_in6);
320 log_error(
"Unsupported address family in sockaddr_size()");
332#ifdef FREECIV_IPV6_SUPPORT
341#ifdef HAVE_GETADDRINFO
365#ifndef FREECIV_IPV6_SUPPORT
390 while (current !=
nullptr) {
395 memcpy(
caddr, current->ai_addr, current->ai_addrlen);
399 current = current->ai_next;
416#ifdef HAVE_GETADDRINFO
446 if (!hp || hp->h_addrtype !=
AF_INET) {
452 memcpy(&
sock4->sin_addr, hp->h_addr, hp->h_length);
468#ifdef FREECIV_IPV6_SUPPORT
501 log_error(
"socket %d: failed to fdopen()", sock);
507 log_error(
"socket %d: write error", sock);
518#ifdef FREECIV_MSWINDOWS
543 log_error(
"socket %d: write error", sock);
569#ifndef FREECIV_IPV6_SUPPORT
577#ifdef FREECIV_IPV6_SUPPORT
587 log_error(
"Port from unsupported address family requested!");
594#ifdef HAVE_GETADDRINFO
612 while (current !=
nullptr && !
unusable) {
618 if (
bind(s, current->ai_addr, current->ai_addrlen) != 0) {
624 current = current->ai_next;
654 if (hp->h_addrtype !=
AF_INET) {
655 log_error(
"Requested IPv4 address for %s, got something else! (%d)",
661 memcpy(&
sock4->sin_addr, hp->h_addr, hp->h_length);
676 log_error(
"None of the ports %d - %d is available.",
void bugreport_request(const char *reason_format,...)
enum announce_type announce
fz_FILE * fz_from_stream(FILE *stream)
#define log_warn(message,...)
#define fc_assert(condition)
#define fc_assert_action(condition, action)
#define log_base(level, message,...)
#define log_error(message,...)
void fc_shutdown_network(void)
bool fc_inet_aton(const char *cp, struct in_addr *inp, bool addr_none_ok)
bool sockaddr_ipv6(union fc_sockaddr *addr)
struct fc_sockaddr_list * net_lookup_service(const char *name, int port, enum fc_addr_family family)
void fc_init_network(void)
void fc_closesocket(int sock)
void sockaddr_debug(union fc_sockaddr *addr, enum log_level lvl)
int find_next_free_port(int starting_port, int highest_port, enum fc_addr_family family, char *net_interface, bool not_avail_ok)
int addr_family_for_announce_type(enum announce_type announce)
int sockaddr_size(union fc_sockaddr *addr)
int fc_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
int fc_readsocket(int sock, void *buf, size_t size)
int fc_writesocket(int sock, const void *buf, size_t size)
void fc_nonblock(int sockfd)
int fc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fc_timeval *timeout)
fz_FILE * fc_querysocket(int sock, void *buf, size_t size)
struct timeval fc_timeval
int fc_snprintf(char *str, size_t n, const char *format,...)
const char * fc_strerror(fc_errno err)
FILE * fc_fopen(const char *filename, const char *opentype)
fc_errno fc_get_errno(void)
#define sz_strlcat(dest, src)
struct sockaddr_in saddr_in4