func (c *StatsdClient) Close() error {
	if nil == c.conn {
		return nil
	}
	return c.conn.Close()
}
Close the UDP connection
package statsd
import (
	"fmt"
	"log"
	"net"
	"os"
	"strings"
	"time"
	"github.com/quipo/statsd/event"
)
type Logger interface {
	Println(v ...interface{})
}
var UDPPayloadSize int = 512
var Hostname string
var errNotConnected = fmt.Errorf("cannot send stats, not connected to StatsD server")
func init() {
	host, err := os.Hostname()
	if nil == err {
		Hostname = host
	}
}
type StatsdClient struct {
	conn           net.Conn
	addr           string
	prefix         string
	eventStringTpl string
	Logger         Logger
}
func NewStatsdClient(addr string, prefix string) *StatsdClient {
	prefix = strings.Replace(prefix, "%HOST%", Hostname, 1)
	return &StatsdClient{
		addr:           addr,
		prefix:         prefix,
		Logger:         log.New(os.Stdout, "[StatsdClient] ", log.Ldate|log.Ltime),
		eventStringTpl: "%s%s:%s",
	}
}
func (c *StatsdClient) String() string {
	return c.addr
}
func (c *StatsdClient) CreateSocket() error {
	conn, err := net.DialTimeout("udp", c.addr, 5*time.Second)
	if err != nil {
		return err
	}
	c.conn = conn
	return nil
}
func (c *StatsdClient) CreateTCPSocket() error {
	conn, err := net.DialTimeout("tcp", c.addr, 5*time.Second)
	if err != nil {
		return err
	}
	c.conn = conn
	c.eventStringTpl = "%s%s:%s\n"
	return nil
}