FAQ
I've built a simple client that sends multiple messages and server that
reads in a loop but that will only print the first message and then does
nothing.

My purpose here is to send lots of messages on the same connection and I am
not interested in a response.

--
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/d/optout.

Search Discussions

  • Rayland at May 6, 2016 at 11:07 am
    It seems to work as intended when using telnet.

    I'm wondering if it has something to do with OS X.
    On Friday, May 6, 2016 at 1:17:08 PM UTC+3, Rayland wrote:

    I've built a simple client that sends multiple messages and server that
    reads in a loop but that will only print the first message and then does
    nothing.

    My purpose here is to send lots of messages on the same connection and I
    am not interested in a response.
    --
    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/d/optout.
  • Manlio Perillo at May 6, 2016 at 11:46 am
    Il giorno venerdì 6 maggio 2016 12:17:08 UTC+2, Rayland ha scritto:
    I've built a simple client that sends multiple messages and server that
    reads in a loop but that will only print the first message and then does
    nothing.

    My purpose here is to send lots of messages on the same connection and I
    am not interested in a response.
    The client tries to read some data from the server, but the server does not
    send anything.
    Since there is only one client, the server waits forever for more data to
    read.

    P.S.:
    The problem has nothing to do with TCP connection reusing.
    When you use the same connection to do several requests, the only problem
    you have is how to differentiate between the different requests.
    You need to define a custom protocol;
    e.g. https://en.wikipedia.org/wiki/Netstring


    Manlio

    --
    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/d/optout.
  • Rayland at May 6, 2016 at 1:01 pm
    It worked. A silly mistake.

    Thank you!
    On Friday, May 6, 2016 at 2:46:04 PM UTC+3, Manlio Perillo wrote:

    Il giorno venerdì 6 maggio 2016 12:17:08 UTC+2, Rayland ha scritto:
    I've built a simple client that sends multiple messages and server that
    reads in a loop but that will only print the first message and then does
    nothing.

    My purpose here is to send lots of messages on the same connection and I
    am not interested in a response.
    The client tries to read some data from the server, but the server does
    not send anything.
    Since there is only one client, the server waits forever for more data to
    read.

    P.S.:
    The problem has nothing to do with TCP connection reusing.
    When you use the same connection to do several requests, the only problem
    you have is how to differentiate between the different requests.
    You need to define a custom protocol; e.g.
    https://en.wikipedia.org/wiki/Netstring


    Manlio
    --
    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/d/optout.
  • Manlio Perillo at May 6, 2016 at 6:48 pm
    Il giorno venerdì 6 maggio 2016 12:17:08 UTC+2, Rayland ha scritto:
    I've built a simple client that sends multiple messages and server that
    reads in a loop but that will only print the first message and then does
    nothing.

    My purpose here is to send lots of messages on the same connection and I
    am not interested in a response.
    Also note that the code for reading a response, in server2.go, is not ideal.
    You have:

         read_len, err := conn.Read(request)
         fmt.Println(string(request))

    but it should be, instead

         n, err := conn.Read(request)
         fmt.Println(string(request[:n])

    That is, you should not use the entire buffer, but only the actual data
    that has been read.
    You should also avoid to allocate a new buffer for each Read.


    Manlio


    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMay 6, '16 at 10:17a
activeMay 6, '16 at 6:48p
posts5
users2
websitegolang.org

2 users in discussion

Rayland: 3 posts Manlio Perillo: 2 posts

People

Translate

site design / logo © 2021 Grokbase