[M3devel] Socket error hacks for Ultrix and OSF?
Jay K
jay.krell at cornell.edu
Mon Feb 4 08:14:56 CET 2013
We have:
WITH errno = GetError() DO
IF errno = EINVAL THEN
(* hack to try to get real errno, hidden due to NBIO bug in connect *)
RefetchError (t.fd);
ELSIF errno = EBADF THEN
(* we'll try the same for EBADF, which we've seen on Alpha *)
RefetchError (t.fd);
END;
END;
PROCEDURE RefetchError(fd: INTEGER) =
(* Awful hack to retrieve a meaningful error from a TCP accept
socket. Only works on Ultrix and OSF. Leaves result
in GetError(). *)
VAR optbuf: int := 0; optlen: socklen_t := BYTESIZE(optbuf);
BEGIN
IF SocketPosix_IsUltrixOrOSF.Value THEN
EVAL getsockopt (fd, IPPROTO_TCP, TCP_NODELAY,
ADR(optbuf), ADR(optlen));
END;
END RefetchError;
does anyone know or believe this is useful code?
Does anyone object to removing it?
I don't believe we'll ever run on Ultrix.
OSF/Tru64 is of very marginal interest.
Posix doesn't bless this code.
It seems ok without this -- it is a subtle matter of precisely which error is raised.
Portable code can't depend on the supposedly better Ultrix/OSF behavior, unless they are substandard and return EINVAL/EBADF when other systems return something more specific.
If I could find this workaround in any half way recently maintained C or C++ (Perl? Python?) I'd feel a lot better. I guess I'll look.
More generally I'd like to see the essentially 4 socket libraries we have (libm3/posix, libm3/win32, m3-comm/win32, m3-comm/posix) merged into one portable C file, and support IPv6...
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130204/6df9f2e3/attachment-0001.html>
More information about the M3devel
mailing list