class: Socket
class definition
changed: #closeFile
remove bad closesocket() code completely
--- a/Socket.st Fri Mar 28 00:06:05 2014 +0100
+++ b/Socket.st Fri Mar 28 09:00:39 2014 +0100
@@ -21,7 +21,6 @@
!Socket primitiveDefinitions!
%{
-
/* #define DGRAM_DEBUG /* */
#include "stxOSDefs.h"
@@ -45,15 +44,6 @@
// linger.onoff=off linger.time= *irrelevant*
//# define SET_LINGER_WHEN_CREATING_SOCKET
-/*
- * mhmh - WIN32-fclose has a problem in trying to close() the socket
- * instead of closesocket()'ing it
- *
- * According to: http://msdn.microsoft.com/ru-ru/library/fxfsw25t%28v=vs.100%29.aspx
- * fclose() does a closesocket() too!
- */
-# define xxCLOSESOCKET_AFTER_FCLOSE
-# define xxCLOSESOCKET_BEFORE_FCLOSE
# ifdef __MINGW__
extern HANDLE _get_osfhandle();
@@ -65,19 +55,14 @@
# define SOCKET_FROM_FD(fd) (fd)
# endif
#else /* not WIN32 */
-
-# define SOCKET_FROM_FD(fd) (fd)
-
+# define SOCKET_FROM_FD(fd) (fd)
+# define closesocket(sock) close(sock)
+# define SOCKET int
#endif /* WIN32 */
#define SOCKET_FROM_FILE(f) (SOCKET_FROM_FD(fileno(f)))
#define SOCKET_FROM_FILE_OBJECT(f) (SOCKET_FROM_FILE(__FILEVal(f)))
-#ifndef WIN32
-# define closesocket(sock) close(sock)
-# define SOCKET int
-#endif
-
#include <stdio.h>
#include <errno.h>
@@ -130,7 +115,6 @@
# define stdout __win32_stdout()
# define stderr __win32_stderr()
#endif
-
%}
! !
@@ -2808,7 +2792,7 @@
# ifdef DO_WRAP_CALLS
{
INT ret;
- /*__setWrapCallDebugging(1,1); */
+ // __setWrapCallDebugging(1,1);
if (__INST(buffered) == true){
/* do a fflush() first, so that fclose() doesn't block
@@ -2820,44 +2804,23 @@
} while((ret < 0) && (__threadErrno == EINTR));
}
-# if defined(WIN32) && defined(CLOSESOCKET_BEFORE_FCLOSE)
- DBGFPRINTF((stderr, "SOCKET: closesocket (%d)\n", sock));
- closesocket(sock);
-# endif
do {
__threadErrno = 0;
ret = (INT)STX_C_NOINT_CALL1("fclose", fclose, fp);
} while ((ret < 0) && (__threadErrno == EINTR));
-# if defined(WIN32) && defined(CLOSESOCKET_AFTER_FCLOSE)
- do {
- __threadErrno = 0;
- ret = (INT)STX_WSA_NOINT_CALL1("closesocket", closesocket, sock);
- } while ((ret < 0) && (__threadErrno == EINTR));
-# endif
- /*__setWrapCallDebugging(1,0);*/
+ // __setWrapCallDebugging(1,0);
}
# else /* !DO_WRAP_CALLS */
-
if (__INST(buffered) == true){
DBGFPRINTF((stderr, "SOCKET: fflush %"_lx_" (%d %d)\n", (INT)fp, fileno(fp), sock));
fflush(fp);
}
-# if defined(CLOSESOCKET_BEFORE_FCLOSE)
- DBGFPRINTF((stderr, "SOCKET: closesocket (%d)\n", sock));
- closesocket(sock);
-# endif
if ((@global(FileOpenTrace) == true) || __debugging__) {
console_fprintf(stderr, "SOCKET: fclose %"_lx_" (%d %d)\n", (INT)fp, fileno(fp), sock);
}
fclose(fp);
-
-# if defined(CLOSESOCKET_AFTER_FCLOSE)
- DBGFPRINTF((stderr, "SOCKET: closesocket (%d)\n", sock));
- closesocket(sock);
-# endif
-
# endif /* !DO_WRAP_CALLS */
}
#endif /* NO_SOCKET */
@@ -4163,10 +4126,10 @@
!Socket class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.297 2014-03-27 23:06:05 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.298 2014-03-28 08:00:39 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.297 2014-03-27 23:06:05 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/Socket.st,v 1.298 2014-03-28 08:00:39 stefan Exp $'
! !