FAQ
In this sample code, I forced client to sleep 3 seconds then write data to
server.
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
127.0.0.1:18888: 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

  • James Bardin at May 7, 2013 at 1:44 pm
    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.

    -jim
    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
    server.
    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
    127.0.0.1:18888: 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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 7, '13 at 7:15a
activeMay 7, '13 at 1:44p
posts2
users2
websitegolang.org

2 users in discussion

Dlin: 1 post James Bardin: 1 post

People

Translate

site design / logo © 2021 Grokbase