FAQ
I'm trying to close a (server side) net.Conn automatically if after
some time there are no more characters to read, or when the client
closes the connection. Is there an easy to do this ?

A possible solution could be reading from the connection and checking
for io.EOF, but then, can Conn.Read() indicate such a situation
without consuming at least one character ?

( I'm not using HTTP, just TCP read/writes )

Thanks!
Rolf

--
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

  • Kyle Lemons at Oct 31, 2013 at 12:22 am
    If you call conn.SetDeadline before each call, you can do that:
    http://godoc.org/net#Conn

    On Wed, Oct 30, 2013 at 6:06 AM, Rolf Veen wrote:

    I'm trying to close a (server side) net.Conn automatically if after
    some time there are no more characters to read, or when the client
    closes the connection. Is there an easy to do this ?

    A possible solution could be reading from the connection and checking
    for io.EOF, but then, can Conn.Read() indicate such a situation
    without consuming at least one character ?

    ( I'm not using HTTP, just TCP read/writes )

    Thanks!
    Rolf

    --
    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.
    --
    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.
  • Dmitry Vyukov at Oct 31, 2013 at 7:26 am
    FTR, if you strive for performance, you can call conn.SetDeadline once,
    remember last read time, and then on errTimeout check if it's a real
    timeout or you need to prolong the timeout.
    This would be especially beneficial if you do many IO operations and expect
    all them to complete before the first deadline.
    But of course it increases complexity somewhat.




    On Thu, Oct 31, 2013 at 4:22 AM, Kyle Lemons wrote:

    If you call conn.SetDeadline before each call, you can do that:
    http://godoc.org/net#Conn

    On Wed, Oct 30, 2013 at 6:06 AM, Rolf Veen wrote:

    I'm trying to close a (server side) net.Conn automatically if after
    some time there are no more characters to read, or when the client
    closes the connection. Is there an easy to do this ?

    A possible solution could be reading from the connection and checking
    for io.EOF, but then, can Conn.Read() indicate such a situation
    without consuming at least one character ?

    ( I'm not using HTTP, just TCP read/writes )

    Thanks!
    Rolf

    --
    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.
    --
    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.
    --
    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
postedOct 31, '13 at 12:18a
activeOct 31, '13 at 7:26a
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase