FAQ
I'm beating my head right now on an issue when http.Server needs to be
reconfigured on a fly - stop listening on given port for example.
Has anyone tried something similar? What did you use to stop "serve"
threads?

--
Alex.


--

Search Discussions

  • Kyle Lemons at Nov 28, 2012 at 10:34 pm
    You can do it in a few ways. The simplest way, but which requires slightly
    more code, is to write the accept loop yourself and go s.Serve(conn) on
    each connection. You can close the listener and signal that the accept
    loop needs to stop when you want to change the port.

    On Wed, Nov 28, 2012 at 1:42 PM, Alex Sergeyev wrote:

    I'm beating my head right now on an issue when http.Server needs to be
    reconfigured on a fly - stop listening on given port for example.
    Has anyone tried something similar? What did you use to stop "serve"
    threads?

    --
    Alex.


    --

    --
  • Dave Cheney at Nov 28, 2012 at 10:34 pm
    It should be possible to do that by creating your own net.Listener
    then your own http.Server, then calling Server.Serve to join the two
    up, if you need to change the underlying listener, then close your
    copy of the listener, which will eventually cause the http.Server to
    exit, but you can create a new Listener and Server in the mean time.
    On Thu, Nov 29, 2012 at 8:42 AM, Alex Sergeyev wrote:
    I'm beating my head right now on an issue when http.Server needs to be
    reconfigured on a fly - stop listening on given port for example.
    Has anyone tried something similar? What did you use to stop "serve"
    threads?

    --
    Alex.


    --
    --
  • Alex Sergeyev at Nov 29, 2012 at 1:14 am
    Thank you Dave and Kyle too,

    makes sense to use special listener.

    --
    Alex.

    On Wednesday, November 28, 2012 5:34:18 PM UTC-5, Dave Cheney wrote:

    It should be possible to do that by creating your own net.Listener
    then your own http.Server, then calling Server.Serve to join the two
    up, if you need to change the underlying listener, then close your
    copy of the listener, which will eventually cause the http.Server to
    exit, but you can create a new Listener and Server in the mean time.
    On Thu, Nov 29, 2012 at 8:42 AM, Alex Sergeyev wrote:
    I'm beating my head right now on an issue when http.Server needs to be
    reconfigured on a fly - stop listening on given port for example.
    Has anyone tried something similar? What did you use to stop "serve"
    threads?

    --
    Alex.


    --
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 28, '12 at 9:42p
activeNov 29, '12 at 1:14a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase