--- a/Socket_win32.st Fri Feb 25 12:44:26 2005 +0100
+++ b/Socket_win32.st Fri Feb 25 18:04:41 2005 +0100
@@ -22,6 +22,9 @@
!Socket primitiveDefinitions!
%{
+#define SET_LINGER_WHEN_CREATING_SOCKET
+/* #define SET_LINGER_WHEN_CLOSING_SOCKET */
+
#undef __BEGIN_INTERRUPTABLE__
#undef __END_INTERRUPTABLE__
#define __BEGIN_INTERRUPTABLE__ ..
@@ -2856,8 +2859,8 @@
option = SO_BROADCAST;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_BROADCAST */
@@ -2869,8 +2872,8 @@
option = SO_CONDITIONAL;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif
@@ -2882,23 +2885,23 @@
option = SO_DEBUG;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_DEBUG */
# ifdef SO_DONTLINGER
- if (option == @symbol(SO_DONTLINGER)) {
- /* Does not block close waiting for unsent data to be sent.
- Setting this option is equivalent to setting SO_LINGER with l_onoff set to zero. */
- option = SO_DONTLINGER;
- level = SOL_SOCKET;
- usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
- else goto argError;
- }
+ if (option == @symbol(SO_DONTLINGER)) {
+ /* Does not block close waiting for unsent data to be sent.
+ Setting this option is equivalent to setting SO_LINGER with l_onoff set to zero. */
+ option = SO_DONTLINGER;
+ level = SOL_SOCKET;
+ usize = sizeof(u.u_bool);
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
+ else goto argError;
+ }
# endif /* SO_DONTLINGER */
# ifdef SO_DONTROUTE
@@ -2910,8 +2913,8 @@
option = SO_DONTROUTE;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_DONTROUTE */
@@ -2922,8 +2925,8 @@
option = SO_KEEPALIVE;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_KEEPALIVE */
@@ -2934,8 +2937,8 @@
option = SO_LINGER;
level = SOL_SOCKET;
usize = sizeof(u.u_linger);
- if (arg1 == true) u.u_linger.l_onoff = 1;
- else if (arg1 == false) u.u_linger.l_onoff = 0;
+ if (arg1 == true) u.u_linger.l_onoff = TRUE;
+ else if (arg1 == false) u.u_linger.l_onoff = FALSE;
else goto argError;
if (arg2 == nil) u.u_linger.l_linger = 0;
else if (__isSmallInteger(arg2))u.u_linger.l_linger = __intVal(arg2);
@@ -2950,8 +2953,8 @@
option = SO_OOBINLINE;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_OOBINLINE */
@@ -2986,8 +2989,8 @@
option = SO_REUSEADDR;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_OOBINLINE */
@@ -2999,8 +3002,8 @@
option = SO_EXCLUSIVEADDRUSE;
level = SOL_SOCKET;
usize = sizeof(u.u_bool);
- if (arg1 == true) u.u_bool = 1;
- else if (arg1 == false) u.u_bool = 0;
+ if (arg1 == true) u.u_bool = TRUE;
+ else if (arg1 == false) u.u_bool = FALSE;
else goto argError;
}
# endif /* SO_OOBINLINE */
@@ -3041,14 +3044,17 @@
file = __FILEVal(fp);
sock = _get_osfhandle( fileno(file) );
+# ifdef SET_LINGER_WHEN_CLOSING_SOCKET
+# ifdef SO_LINGER
{
struct linger l;
l.l_onoff = 1;
- l.l_linger = 10;
+ l.l_linger = 30;
setsockopt( sock, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
}
-
+# endif
+# endif
# ifdef DO_WRAP_CALLS
{ int ret;
@@ -4408,6 +4414,17 @@
}
}
# endif /* SO_REUSEADDR */
+# ifdef SET_LINGER_WHEN_CREATING_SOCKET
+# ifdef SO_LINGER
+ {
+ struct linger l;
+
+ l.l_onoff = 1;
+ l.l_linger = 30;
+ setsockopt( sock, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
+ }
+# endif
+# endif
/*
* make it blocking
*/
@@ -4696,5 +4713,5 @@
!Socket class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/Attic/Socket_win32.st,v 1.35 2005-02-23 12:33:40 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Attic/Socket_win32.st,v 1.36 2005-02-25 17:04:41 cg Exp $'
! !