Hi Janne I don't think that is the problem since the problem persists even after inserting a 4 second wait between closing the connection from the far side and writing to the near side.
On Tuesday, April 10, 2018 at 5:02:32 PM UTC+1, Janne Snabb wrote: > > Your TCP FIN is still in transit or not yet processed by the other TCP > stack when you issue the first write. > > TCP is not synchronous even if running on same host. > > > Janne Snabb > sn...@epipe.com <javascript:> > > On 2018-04-10 17:58, pierspo...@gmail.com <javascript:> wrote: > > Hi > > > > I'm trying to understand what is going on under the hood here. > > > > I would expect a net.Conn after being closed from the far side, to issue > > an error if the near side then tries to write to it. On my local machine > > an error is returned on the second write, on the go playground all > > writes succeed. > > > > The test is shown below and is also here > > - https://play.golang.org/p/EFYX_ZehMKs > > > > Thanks for any insight, > > > > Piers > > > > | > > func TestDetectClosedConnectionWhenWriting(t *testing.T) { > > listener, err := net.Listen("tcp", ":0") > > if err != nil { > > t.Fatal(err) > > } > > > > wait := make(chan struct{}) > > go func() { > > conn, err := listener.Accept() > > if err != nil { > > t.Fatal(err) > > } > > err = conn.Close() > > if err != nil { > > t.Fatal(err) > > } > > wait <- struct{}{} > > }() > > > > conn, err := net.Dial("tcp", listener.Addr().String()) > > if err != nil { > > t.Fatal(err) > > } > > <-wait > > for i := 0; i < 100; i++ { > > println(i) > > _, err = conn.Write([]byte("b")) > > if err != nil { > > break > > } > > } > > if err == nil { > > t.Fatal("expecting error to be returned when writing") > > } > > t.Fatal("expecting error to be a permanent net.OpError") > > } > > > > | > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to golang-nuts...@googlegroups.com <javascript:> > > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.