Hi Ed,

I finally looked at this problem, and I think this is just an  
artifact of how TCP/IP works. Same thing happens in Java for example:

BeanShell> s = new java.net.ServerSocket(8000);
ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=8000]
BeanShell> c = s.accept().getOutputStream();
[EMAIL PROTECTED]
BeanShell> c.write("hey".getBytes());
BeanShell> c.write("hey".getBytes());
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        ...

Note that Java's socket streams are not buffered unless wrapped in a  
BufferedOutputStream, so there's no flush() here.

I did observe it blocking on the third write though, but only on  
Linux. This looks like an oddity in the way select() is implemented  
on Linux, and it doesn't appear like I can do anything about it.

User code is supposed to use combinators like with-stream which close  
the stream if there's an error. If you're managing a pool of client  
connections, you should write your own logic to close the streams if  
there's an error.

Closing the stream from inside the I/O code won't be sufficient  
anyway, since errors originating from outside the I/O code won't be  
able close the streams unless you already have exception handling logic.

Slava

On 1-Feb-07, at 5:03 PM, Eduardo Cavazos wrote:

> Slava,
>
> Here's a simple test case on a localhost.
>
> factor:
>
>       8000 <server> dup accept
>
> xterm:
>
>       telnet locahost 8000
>       <manually close connection>
>
> factor:
>
>       "hey" over stream-print dup stream-flush
>       ! this doesn't produce an error. shouldn't it?
>
>       "hey" over stream-print dup stream-flush
>       ! this time I do get an error:
>       ! Error on fd 4: Broken pipe
>       ! Debugger commands: ...
>
>       "hey" over stream-print dup stream-flush
>       ! factor is now blocked.
>
> Why isn't there an error message on the first send? Why does Factor  
> block on
> the third send? When Factor notices a "Broken pipe" error on a  
> stream, should
> Factor mark the stream as closed? Maybe this only makes sense for  
> certain
> kinds of errors. Perhaps it should be up to the programmer to catch  
> errors
> and mark the stream closed manually.
>
> Ed
>
> ---------------------------------------------------------------------- 
> ---
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel? 
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to