FAQ
This may be of some help: http://jan.newmarch.name/go/

On Tuesday, September 18, 2012 5:51:07 AM UTC+2, melissa...@gmail.com wrote:

do any of you know of a good site that has examples on when and how to use
the udp functions such as ResolveUDP, DialUDP, etc.? i've been reading the
golang.org/pkg pages and i don't quite understand how to use them.

Thanks!
On Friday, November 27, 2009 8:28:12 PM UTC-5, ish wrote:

The following server code has a problem. The write by server to
connection always fails.
I have not been able to find the solution.
--
package main

import (
"fmt";
"net";
"os";
"strings";
)

func main() {
var buf [1000]byte;
sout := "The answer";
bout := strings.Bytes(sout);

laddr, err := net.ResolveUDPAddr("127.0.0.1:6854");
if err != nil { fmt.Println("Resolv.."); os.Exit(1); }

c, erl := net.ListenUDP("udp", laddr);
if erl != nil { fmt.Println("Listen.."); os.Exit(1); }

n, erd := c.Read(buf[0:128]);
if erd != nil { fmt.Println("Read.."); os.Exit(1); }
fmt.Println("Read: ", n);
fmt.Println("Writing: ", len(bout));
_, erw := c.Write(bout); //fails
if erw != nil { fmt.Println("Write.."); os.Exit(1); }

fmt.Print("Main stops\n");
}
--
-ish
--

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 4 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 18, '12 at 4:33a
activeSep 19, '12 at 3:18a
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase