[M3devel] win32 vs. Posix struct_linger code backwards??

Jay jay.krell at cornell.edu
Tue Jan 20 13:20:03 CET 2009


Isn't this highly suspicious?

It looks like Win32 turns "linger" off, and Posix turns it on.
 
Win32:
PROCEDURE InitSock (sock: WinSock.SOCKET) =
  (* We assume that the runtime ignores SIGPIPE signals *)
  (* LL = mu *)
  VAR
    one := 1;
    linger := WinSock.struct_linger{0, 0};
  BEGIN
    (*****
    EVAL WinSock.setsockopt (sock, WinSock.SOL_SOCKET, WinSock.SO_SNDBUF,
                             ADR(SysSendBufSize), BYTESIZE(SysSendBufSize));
    EVAL WinSock.setsockopt (sock, WinSock.SOL_SOCKET, WinSock.SO_RCVBUF,
                             ADR(SysRcvBufSize), BYTESIZE(SysRcvBufSize));
    ******)
    EVAL WinSock.setsockopt (sock, WinSock.SOL_SOCKET, WinSock.SO_LINGER,
                             ADR(linger), BYTESIZE(linger));
    (**** WinSock documentation warns that this may cause problems
    ****)
    EVAL WinSock.setsockopt (sock, WinSock.IPPROTO_TCP, WinSock.TCP_NODELAY,
                             ADR(one), BYTESIZE(one));
  END InitSock;

Posix:

PROCEDURE InitStream (fd: CARDINAL)
  RAISES {OSError.E} =
  (* We assume that the runtime ignores SIGPIPE signals *)
  VAR
    one := 1;
    linger := Usocket.struct_linger{1, 1};
  BEGIN
    (*****
    EVAL Usocket.setsockopt(fd, Usocket.SOL_SOCKET, Usocket.SO_SNDBUF,
                            ADR(SysSendBufSize), BYTESIZE(SysSendBufSize));
    EVAL Usocket.setsockopt(fd, Usocket.SOL_SOCKET, Usocket.SO_RCVBUF,
                            ADR(SysRcvBufSize), BYTESIZE(SysRcvBufSize));
    ******)
    EVAL Usocket.setsockopt(fd, Usocket.SOL_SOCKET, Usocket.SO_LINGER,
                            ADR(linger), BYTESIZE(linger));
    EVAL Usocket.setsockopt(fd, Uin.IPPROTO_TCP, TCP_NODELAY,
                            ADR(one), BYTESIZE(one));
    MakeNonBlocking (fd);
  END InitStream;


More information about the M3devel mailing list