func packNetAddr(addr net.Addr, buf []byte) {
    ipport := addr.String()
    pair := strings.Split(ipport, ":")
    ipstr, portstr := pair[0], pair[1]
    port, err := strconv.Atoi(portstr)
    if err != nil {
        panic(fmt.Sprintf("invalid address %s", ipport))
    }
    copy(buf[:4], net.ParseIP(ipstr).To4())
    buf[4] = byte(port / 256)
    buf[5] = byte(port % 256)
}
Convert a IP:Port string to a byte array in network order.
e.g.: 74.125.31.104:80 -> [74 125 31 104 0 80]
package main
import (
    "io"
    "os"
    "fmt"
    "log"
    "net"
    "strings"
    "strconv"
)
var LISTEN string   