There's no way for a TCP socket to know that the remote end has closed.
You will always have make one more send to get an RST in return to signal
that it closed.
If you send again, you should get a "broken pipe" error.

On Tuesday, May 7, 2013 3:15:20 AM UTC-4, dlin wrote:

In this sample code, I forced client to sleep 3 seconds then write data to
And in server side, it read and wait 1 second at most.

I think the server side have already closed the socket.
But, why client side still write to socket without any error code returned?

code: http://play.golang.org/p/bujqJsivON

2013/05/07 15:05:05.554646 srv.go:74: cli sleep 3 seconds
2013/05/07 15:05:06.555119 srv.go:58: Err: srv read read tcp i/o timeout
2013/05/07 15:05:06.555199 srv.go:50: srv close conn
2013/05/07 15:05:06.557232 srv.go:41: srv close listener
2013/05/07 15:05:08.555172 srv.go:76: cli will write
2013/05/07 15:05:08.555407 srv.go:82: cli wrote 9 bytes
2013/05/07 15:05:08.555428 srv.go:71: cli close sock
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupgolang-nuts @
postedMay 7, '13 at 7:15a
activeMay 7, '13 at 1:44p

2 users in discussion

Dlin: 1 post James Bardin: 1 post



site design / logo © 2022 Grokbase