wrowe 01/12/07 15:14:19
Modified: network_io/win32 sockets.c
Log:
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.
Revision Changes Path
1.67 +5 -4 apr/network_io/win32/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- sockets.c 2001/11/26 15:53:37 1.66
+++ sockets.c 2001/12/07 23:14:18 1.67
@@ -121,6 +121,7 @@
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 @@
/* 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;