Subject: [clisp-list] proposed modifications to SOCKET-STATUS

From: Sam Steingold <[email-masked]>
Date: Sat Jan 25 18:53:03 2003

SOCKET-STATUS is different from select(): it returns non-NIL when the
the corresponding operation would be successful.  I.e., it returns NIL
at EOF.
we can make SOCKET-STATUS distinguish between WAIT and EOF conditions
and return :IO/:INPUT/:APPEND/:EOF/:OUTPUT/:WAIT (6 possible replies
instead of 4).

please try the appended patch.

note that this change is __NOT__ backwards compatible.
if you do not like the change please do voice your opinion ASAP!

Another thing I always disliked about SOCKET-STATUS is that it conses up
a new list whenever it is called on a list of objects (the usual case
with most applications).
What about making it modify the list it accepts?
i.e., if the list is

        ((socket1 direction1)
         (socket1 direction2)
         ...)

then it will destructively modify it and return it like this:

        ((socket1 direction1 . status)
         (socket1 direction2 . status)
         ...)

then this same list can be passed to SOCKET-STATUS again.
this change will be backwards compatible because now the element of the
list must be a cons (socket . direction), so the new argument would
just signal an error on '(direction) being and invalid direction spec.
do people want it?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Computers are like air conditioners: they don't work with open windows!

--- stream.d.~1.337.~	2003-01-24 19:07:53.000000000 -0500
+++ stream.d	2003-01-25 11:41:35.000000000 -0500
@@ -14909,7 +14909,8 @@
   object sock = (consp(socket) ? (object)Car(socket) : socket);
   direction_t dir = (consp(socket)?check_direction(Cdr(socket)):DIRECTION_IO);
   SOCKET in_sock = INVALID_SOCKET, out_sock = INVALID_SOCKET;
-  bool char_p = true, rd = false, wr = false;
+  bool char_p = true, wr = false;
+  signean rd = ls_wait;
   stream_handles(sock,true,&char_p,
                  READ_P(dir)  ? &in_sock  : NULL,
                  WRITE_P(dir) ? &out_sock : NULL);
@@ -14917,17 +14918,17 @@
     if (FD_ISSET(in_sock,errorfds)) return S(Kerror);
     if (socket_server_p(sock))
       return FD_ISSET(in_sock,readfds) ? T : NIL;
-    rd = FD_ISSET(in_sock,readfds)
-      && (ls_avail_p(char_p ? listen_char(sock) : listen_byte(sock)));
+    if (FD_ISSET(in_sock,readfds))
+      rd = (char_p ? listen_char(sock) : listen_byte(sock));
   }
   if (out_sock != INVALID_SOCKET) {
     if (FD_ISSET(out_sock,errorfds)) return S(Kerror);
     wr = FD_ISSET(out_sock,writefds);
   }
-  if      ( rd && !wr) return S(Kinput);
-  else if (!rd &&  wr) return S(Koutput);
-  else if ( rd &&  wr) return S(Kio);
-  else                 return NIL;
+  if (ls_avail_p(rd)) return wr ? S(Kio)     : S(Kinput);
+  if (ls_eof_p(rd))   return wr ? S(Kappend) : S(Keof);
+  if (ls_wait_p(rd))  return wr ? S(Koutput) : S(Kwait);
+  NOTREACHED;
 }
 #undef READ_P
 #undef WRITE_P

---

From: Sam Steingold <[email-masked]>
Date: Wed Jan 29 11:44:03 2003

please read
<http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/clisp/clisp/doc/impnotes.html?rev=HEAD&content-type=text/html#so-status>
and try CVS head
comments, bug reports and suggestions are welcome

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Between grand theft and a legal fee, there only stands a law degree.