FAQ
Hi,

I recently tried to create an application which should serve both TCP and
UDP. You can find a short snippet here:

http://play.golang.org/p/phgV0JFzYs

The funny thing is, that if I only serve TCP (Line 85, remove "go"; do not
run as goroutine) and I telnet to the TCP, I reveice the "hello" string.
When I serve both, I do not receive anything.

Can someone hint me to the right direction?

Thank you very much in advance.

Seong

--

Search Discussions

  • Roger peppe at Oct 22, 2012 at 11:43 am
    Your problem is that you've got an infinitely spinning loop in UdpSrv.Serve,
    which is stopping any other goroutine from running.
    If you change that to select{} (a more carbon-efficient alternative),
    your program works.

    BTW, there's no need to call ResolveUDPAddr - you can use net.ListenPacket.

    http://play.golang.org/p/VGaFaDESjO
    On 22 October 2012 10:07, Seong-Min Kang wrote:
    Hi,

    I recently tried to create an application which should serve both TCP and
    UDP. You can find a short snippet here:

    http://play.golang.org/p/phgV0JFzYs

    The funny thing is, that if I only serve TCP (Line 85, remove "go"; do not
    run as goroutine) and I telnet to the TCP, I reveice the "hello" string.
    When I serve both, I do not receive anything.

    Can someone hint me to the right direction?

    Thank you very much in advance.

    Seong

    --
    --
  • Seong-Min Kang at Oct 22, 2012 at 1:14 pm
    Oh d'oh....

    Am Montag, 22. Oktober 2012 13:43:37 UTC+2 schrieb rog:
    Your problem is that you've got an infinitely spinning loop in
    UdpSrv.Serve,
    which is stopping any other goroutine from running.
    If you change that to select{} (a more carbon-efficient alternative),
    your program works.
    that's what you get when you plan to implement the blocking loop later :/

    Thank you very much.

    Cheers Seong

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 22, '12 at 10:38a
activeOct 22, '12 at 1:14p
posts3
users2
websitegolang.org

2 users in discussion

Seong-Min Kang: 2 posts Roger peppe: 1 post

People

Translate

site design / logo © 2021 Grokbase