| 23 |
|
*/ |
| 24 |
|
|
| 25 |
|
#include "stdinc.h" |
| 26 |
– |
#ifndef _WIN32 |
| 26 |
|
#include <netinet/in_systm.h> |
| 27 |
|
#include <netinet/ip.h> |
| 28 |
|
#include <netinet/tcp.h> |
| 30 |
– |
#endif |
| 29 |
|
#include "fdlist.h" |
| 30 |
|
#include "s_bsd.h" |
| 31 |
|
#include "client.h" |
| 78 |
|
else |
| 79 |
|
{ |
| 80 |
|
ServerInfo.can_use_v6 = 1; |
| 83 |
– |
#ifdef _WIN32 |
| 84 |
– |
closesocket(v6); |
| 85 |
– |
#else |
| 81 |
|
close(v6); |
| 87 |
– |
#endif |
| 82 |
|
} |
| 83 |
|
#else |
| 84 |
|
ServerInfo.can_use_v6 = 0; |
| 94 |
|
int |
| 95 |
|
get_sockerr(int fd) |
| 96 |
|
{ |
| 103 |
– |
#ifndef _WIN32 |
| 97 |
|
int errtmp = errno; |
| 105 |
– |
#else |
| 106 |
– |
int errtmp = WSAGetLastError(); |
| 107 |
– |
#endif |
| 98 |
|
#ifdef SO_ERROR |
| 99 |
|
int err = 0; |
| 100 |
|
socklen_t len = sizeof(err); |
| 156 |
|
setsockopt(fd, IPPROTO_IP, IP_TOS, &opt, sizeof(opt)); |
| 157 |
|
#endif |
| 158 |
|
|
| 169 |
– |
#ifndef _WIN32 |
| 159 |
|
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK); |
| 171 |
– |
#endif |
| 160 |
|
|
| 161 |
|
return NULL; |
| 162 |
|
} |
| 646 |
|
/* Error? */ |
| 647 |
|
if (retval < 0) |
| 648 |
|
{ |
| 661 |
– |
#ifdef _WIN32 |
| 662 |
– |
errno = WSAGetLastError(); |
| 663 |
– |
#endif |
| 649 |
|
/* |
| 650 |
|
* If we get EISCONN, then we've already connect()ed the socket, |
| 651 |
|
* which is a good thing. |
| 704 |
|
*/ |
| 705 |
|
fd = socket(family, sock_type, proto); |
| 706 |
|
if (fd < 0) |
| 722 |
– |
{ |
| 723 |
– |
#ifdef _WIN32 |
| 724 |
– |
errno = WSAGetLastError(); |
| 725 |
– |
#endif |
| 707 |
|
return -1; /* errno will be passed through, yay.. */ |
| 727 |
– |
} |
| 708 |
|
|
| 709 |
|
execute_callback(setup_socket_cb, fd); |
| 710 |
|
|
| 739 |
|
*/ |
| 740 |
|
newfd = accept(lptr->fd.fd, (struct sockaddr *)pn, (socklen_t *)&addrlen); |
| 741 |
|
if (newfd < 0) |
| 762 |
– |
{ |
| 763 |
– |
#ifdef _WIN32 |
| 764 |
– |
errno = WSAGetLastError(); |
| 765 |
– |
#endif |
| 742 |
|
return -1; |
| 767 |
– |
} |
| 743 |
|
|
| 744 |
|
#ifdef IPV6 |
| 745 |
|
remove_ipv6_mapping(pn); |