Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Skip Tavakkolian
that makes sense. thanks.

On Sat, Feb 4, 2017 at 5:38 AM Charles Forsyth 
wrote:

>
> On 4 February 2017 at 01:56, Skip Tavakkolian 
> wrote:
>
> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
> transition to Finwait1.
>
>
> i'd make it a "read" or "write" parameter to the existing "hangup"
> message. older implementations that don't accept the parameter will give an
> error on the request because the current tcp.c doesn't accept a parameter
>


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Skip Tavakkolian
yes, i'm still trying to find a real situation where this would be
critical. i asked go-nuts list for production examples at the same time as
the start of this thread. no answers yet.

On Sat, Feb 4, 2017 at 3:31 AM Charles Forsyth 
wrote:

> it's also funny that the rationale seems to be to pass the same
> conformance test for Go that once had it added to Inferno so it would pass
> a Java test but it was never otherwise used for reasons already given, so I
> took it out again.
>
> On 4 February 2017 at 10:11, Charles Forsyth 
> wrote:
>
> I did once have a use for this in an o/s of mine, in a sort of network
> pipe to servers, but it was so variably implemented by other systems (data
> was flushed, or not) I gave it up as not particularly useful in practice,
> except between two known systems that did what you wanted.
>
> On 4 February 2017 at 09:58, Charles Forsyth 
> wrote:
>
>
> On 4 February 2017 at 01:56, Skip Tavakkolian 
> wrote:
>
> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
> transition to Finwait1.
>
>
> i'd make it a "read" or "write" parameter to the existing "hangup"
> message. older implementations that don't accept the parameter will give an
> error on the request because the current tcp.c doesn't accept a parameter
>
>
>
>


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Fran. J Ballesteros
I used half closes to put go chans in the network for my weird chan based 
network
calls. 
But the code works without such feature. 
Being just that, I dont know if it counts. 

> El 5 feb 2017, a las 5:39, Skip Tavakkolian  
> escribió:
> 
> yes, i'm still trying to find a real situation where this would be critical. 
> i asked go-nuts list for production examples at the same time as the start of 
> this thread. no answers yet.
> 
>> On Sat, Feb 4, 2017 at 3:31 AM Charles Forsyth  
>> wrote:
>> it's also funny that the rationale seems to be to pass the same conformance 
>> test for Go that once had it added to Inferno so it would pass a Java test 
>> but it was never otherwise used for reasons already given, so I took it out 
>> again.
>> 
>> On 4 February 2017 at 10:11, Charles Forsyth  
>> wrote:
>> I did once have a use for this in an o/s of mine, in a sort of network pipe 
>> to servers, but it was so variably implemented by other systems (data was 
>> flushed, or not) I gave it up as not particularly useful in practice, except 
>> between two known systems that did what you wanted.
>> 
>> On 4 February 2017 at 09:58, Charles Forsyth  
>> wrote:
>> 
>> On 4 February 2017 at 01:56, Skip Tavakkolian  
>> wrote:
>> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and 
>> transition to Finwait1.
>> 
>> i'd make it a "read" or "write" parameter to the existing "hangup" message. 
>> older implementations that don't accept the parameter will give an error on 
>> the request because the current tcp.c doesn't accept a parameter
>> 
>> 


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Skip Tavakkolian
cool.

On Fri, Feb 3, 2017 at 10:35 PM Bakul Shah  wrote:

> For the shut_rd case, I think a cleaner impl is to send RST *only* if
> there is pending data (received but not read by the user) or new data is
> received after the read end is closed. At the moment I don't recall what
> BSD does but you don't have to allow draining once the read end is closed.
> Just drain and RST! Any user reads should fail.
>
> I recall having to deal with this in the past while working on a packet
> level network proxy. No access to that code now so the above is from
> memory.
>
>
>
> Sent from my iPad
> On Feb 3, 2017, at 5:56 PM, Skip Tavakkolian 
> wrote:
>
> Has anyone looked into implementing this?  Can anyone comment on the
> details?
>
> For the curious, this is described here:
> https://tools.ietf.org/html/rfc1122#page-87
> Go net package (https://github.com/golang/go/issues/17906).
>
> As I understand it, one would only worry about 'shutdown' if the
> connection is in 'Established' state. It is not clear to me what the state
> should transition to when the read-end is closed (i.e. shut_rd).  Also,
> there doesn't not seem to be consistency between different implementations
> (Windows,Linux, *BSD) on what should happen to what's already in the read
> queue; should it be allowed to drain to the reader or discarded immediately?
>
> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
> transition to Finwait1.
>
> I think the correct mechanics to handle this would be to add two new
> messages in tcpctl (/sys/src/9/ip/tcp.c). Then, roughly something like this:
>
> case 'shut_rd' :
>  if (Etablished) {
>   qhangup(rq);
>   send(RST);  // Windows does this and RFC1122 seems to recommend it.
> Linux does not.
>   tcb->rcv.blocked = 1;  // all that's needed?
>   tcb->rcv.wnd = 0;
>   tcpsetstate()  // not sure what it should be or should stay
> Established?
> }
>
> case 'shut_wr':
>   if (Established) {
> qhangup(wq);
> send(FIN)
> tcpsetstate(Finwait_1)
>   }
>
>
>


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Bakul Shah
I think shutdown(sock, SHU_RD) is mainly to let the sender generate an SIGPIPE 
signal in case it has sent data on a closed direction of a connection. But I 
think this is only for completeness. Almost always you’d use close(sock). At 
least I have not found a usecase when I’d want to shutdown the read-end but 
continue sending on write-end. 

> On Feb 4, 2017, at 8:39 PM, Skip Tavakkolian  
> wrote:
> 
> yes, i'm still trying to find a real situation where this would be critical. 
> i asked go-nuts list for production examples at the same time as the start of 
> this thread. no answers yet.
> 
> On Sat, Feb 4, 2017 at 3:31 AM Charles Forsyth  > wrote:
> it's also funny that the rationale seems to be to pass the same conformance 
> test for Go that once had it added to Inferno so it would pass a Java test 
> but it was never otherwise used for reasons already given, so I took it out 
> again.
> 
> On 4 February 2017 at 10:11, Charles Forsyth  > wrote:
> I did once have a use for this in an o/s of mine, in a sort of network pipe 
> to servers, but it was so variably implemented by other systems (data was 
> flushed, or not) I gave it up as not particularly useful in practice, except 
> between two known systems that did what you wanted.
> 
> On 4 February 2017 at 09:58, Charles Forsyth  > wrote:
> 
> On 4 February 2017 at 01:56, Skip Tavakkolian  > wrote:
> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and transition 
> to Finwait1.
> 
> i'd make it a "read" or "write" parameter to the existing "hangup" message. 
> older implementations that don't accept the parameter will give an error on 
> the request because the current tcp.c doesn't accept a parameter
> 
> 



Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Charles Forsyth
On 4 February 2017 at 01:56, Skip Tavakkolian 
wrote:

> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
> transition to Finwait1.


i'd make it a "read" or "write" parameter to the existing "hangup" message.
older implementations that don't accept the parameter will give an error on
the request because the current tcp.c doesn't accept a parameter


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Charles Forsyth
I did once have a use for this in an o/s of mine, in a sort of network pipe
to servers, but it was so variably implemented by other systems (data was
flushed, or not) I gave it up as not particularly useful in practice,
except between two known systems that did what you wanted.

On 4 February 2017 at 09:58, Charles Forsyth 
wrote:

>
> On 4 February 2017 at 01:56, Skip Tavakkolian 
> wrote:
>
>> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
>> transition to Finwait1.
>
>
> i'd make it a "read" or "write" parameter to the existing "hangup"
> message. older implementations that don't accept the parameter will give an
> error on the request because the current tcp.c doesn't accept a parameter
>


Re: [9fans] adding TCP half-duplex close

2017-02-04 Thread Charles Forsyth
it's also funny that the rationale seems to be to pass the same conformance
test for Go that once had it added to Inferno so it would pass a Java test
but it was never otherwise used for reasons already given, so I took it out
again.

On 4 February 2017 at 10:11, Charles Forsyth 
wrote:

> I did once have a use for this in an o/s of mine, in a sort of network
> pipe to servers, but it was so variably implemented by other systems (data
> was flushed, or not) I gave it up as not particularly useful in practice,
> except between two known systems that did what you wanted.
>
> On 4 February 2017 at 09:58, Charles Forsyth 
> wrote:
>
>>
>> On 4 February 2017 at 01:56, Skip Tavakkolian > > wrote:
>>
>>> Shutting down the write-end (i.e. 'shut_wr'), should send FIN, and
>>> transition to Finwait1.
>>
>>
>> i'd make it a "read" or "write" parameter to the existing "hangup"
>> message. older implementations that don't accept the parameter will give an
>> error on the request because the current tcp.c doesn't accept a parameter
>>
>
>