diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2001-12-07 23:14:18 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2001-12-07 23:14:18 +0000 |
commit | e704d246caa1cb36870ea8626efa2c8c34c23a00 (patch) | |
tree | 9cf6d1ecfacdafc946d2f28ae6d93ac12912983e /network_io | |
parent | f8328b0a1548b083771c312326cd30a40816092a (diff) | |
download | libapr-e704d246caa1cb36870ea8626efa2c8c34c23a00.tar.gz |
APR DOES NOT simply support TCP STREAM sockets.
We need to look at if IPPROTO_TCP is absolutely required, and if the
correct proto will be inferred for things such as SOCK_DGRAM for udp.
In any case, the existing code was certainly very ugly and not nice.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62609 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/win32/sockets.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/network_io/win32/sockets.c b/network_io/win32/sockets.c index d764e3418..d6635abde 100644 --- a/network_io/win32/sockets.c +++ b/network_io/win32/sockets.c @@ -121,6 +121,7 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int ofamily, int type, apr_pool_t *cont) { int family = ofamily; + int downgrade = (family == AF_UNSPEC); if (family == AF_UNSPEC) { #if APR_HAVE_IPV6 @@ -145,19 +146,19 @@ APR_DECLARE(apr_status_t) apr_socket_create(apr_socket_t **new, int ofamily, /* For right now, we are not using socket groups. We may later. * No flags to use when creating a socket, so use 0 for that parameter as well. */ - (*new)->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + (*new)->sock = socket(family, type, /* IPPROTO_TCP */ 0); #endif #if APR_HAVE_IPV6 - if ((*new)->sock == INVALID_SOCKET && ofamily == AF_UNSPEC) { + if ((*new)->sock == INVALID_SOCKET && downgrade) { family = AF_INET; - (*new)->sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + (*new)->sock = socket(family, type, /* IPPROTO_TCP */ 0); } #endif if ((*new)->sock == INVALID_SOCKET) { return apr_get_netos_error(); } - set_socket_vars(*new, AF_INET, type); + set_socket_vars(*new, family, type); (*new)->timeout = -1; (*new)->disconnected = 0; |