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

From: [email-masked] (Don Cohen)
Date: Sun Jan 26 13:16:03 2003

> 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).
Previous values were nil, io, input, output, error (5, not 4).
I gather io, input and output mean the same as before?
So nil,error now map to append, eof, wait?
Could you please tell us what those new values mean?
I suppose I should be able to tell from the diff ... if I knew
what all the c functions meant!

It looks like nil -> wait ?  
Under what circumstances does that occur?
(I never understood when nil would be returned either.)

It seems to me that a socket stream has two different eof's -
Each side can close the direction from itself (by sending a FIN).
Does append mean that you've reached eof on input but not output?
I suppose when both are closed then the stream is closed, and at
that point you get what value?  Before it would have been error?
I gather at least one goal here is to distinguish between not being
able to read/write temporarily vs permanently.  That would suggest
instead of encoding two values for each of two directions you want
three values for two directions, which already gives 9 values.
But then there's this funny nil/wait thing.  Is that also possible
in each direction (giving 16)? or just a 10'th value?

Of course, there's the whole can of worms with multibyte characters
to worry about, but I'll not even think about that yet.

 > note that this change is __NOT__ backwards compatible.
 > if you do not like the change please do voice your opinion ASAP!
Perhaps it could be made backward compatible?

 > 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).

On this one I agree.

 > 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.

Good, then what you meant to say above was:

 if the list is
          ((socket1 direction1 . x) ...)
 it will replace x with the new status.

---

From: Sam Steingold <[email-masked]>
Date: Tue Jan 28 17:49:12 2003

> * In message <[email-masked]>
> * On the subject of "[clisp-list] proposed modifications to SOCKET-STATUS"
> * Sent on Sun, 26 Jan 2003 13:14:19 -0800
> * Honorable [email-masked] (Don Cohen) writes:
>

:ERROR is different and it stays there, of course.

> I gather io, input and output mean the same as before?
yes.

> So nil,error now map to append, eof, wait?

no.  nil maps to :wait.
:error --> :error
:append was :output
:eof was nil.

> Could you please tell us what those new values mean?

:ERROR: next i/o will generate an error
:INPUT: only input is possible (or requested)
:OUTPUT: only output is possible (or requested)
:IO: both input and output are possible
:EOF: input --> EOF, output impossible or not requested
:APPEND: output possible, input --> EOF
:WAIT: both output & input --> hang (or not requested)

> Perhaps it could be made backward compatible?

no.  the granularity is now different, more situations are
discriminated between,

>  it will replace x with the new status.

yes.

-- 
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>
Don't hit a man when he's down -- kick him; it's easier.

---

From: [email-masked] (Don Cohen)
Date: Tue Jan 28 21:41:03 2003

> :WAIT: both output & input --> hang (or not requested)

What's this requested stuff?
Under what circumstance would io cause an error?  Socket closed?
(Hmm, even that should give eof on input, right?)

So, if I understand, input can do three things:
 - wait
 - eof
 - return immediately with "real" input
whereas output can only do 2:
 - wait
 - return immediately 

You call these

		input
	  	wait	real	eof
 output	      +-------------------------
	return| output	io	append
	 wait |	wait	input	eof

It seems to me that you might want another row for output when 
the output direction has been closed.  In that case I guess output
would give an error?
So right now you return error in that case regardless of what input
would give?  Or maybe in clisp once you close you can no longer read
either, i.e., the two directions don't really close independently as
in tcp.
(Am I making sense to you ?)

---

From: Sam Steingold <[email-masked]>
Date: Wed Jan 29 07:28:02 2003

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] proposed modifications to SOCKET-STATUS"
> * Sent on Tue, 28 Jan 2003 21:38:14 -0800

see <http://clisp.cons.org/impnotes/socket.html#so-status>,
specifically the table "Possible values of socket-stream-or-list".

> Under what circumstance would io cause an error?

see select(2), "exceptfds".

> whereas output can only do 2:

it can also signal an error if the other side has closed the
connection, but I don't know how to check for this.

> the output direction has been closed.  In that case I guess output

yes, almost:

[7]> (format o "foo")
NIL
[8]> (format o "foo~%")

[stream.d:13629] 
*** - UNIX error 32 (EPIPE): Broken pipe, child process terminated or socket closed
1. Break [9]> 

i.e., the error is only after a NL.

how do I check for this?

-- 
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>
Life is like a diaper -- short and loaded.