func NewRep(endpoints string) (*Sock, error) {
	s := NewSock(Rep)
	return s, s.Attach(endpoints, true)
}
NewRep creates a Rep socket and calls Attach.
The socket will Bind by default.
package goczmq
import "C"
import (
	"os"
	"runtime"
	"strings"
	"unsafe"
)
type Sock struct {
	zsockT    *C.struct__zsock_t
	file      string
	line      int
	zType     int
	clientIDs []string
}
func init() {
	if err := os.Setenv("ZSYS_SIGHANDLER", "false"); err != nil {
		panic(err)
	}
}
func (s *Sock) GetLastClientID() []byte {
	id := []byte(s.clientIDs[0])
	s.clientIDs = s.clientIDs[1:]
	return id
}
func (s *Sock) SetLastClientID(id []byte) {
	s.clientIDs = append(s.clientIDs, string(id))
}
func NewSock(t int) *Sock {
	var s *Sock
	_, file, line, ok := runtime.Caller(1)
	if ok {
		s = &Sock{
			file:      file,
			line:      line,
			zType:     t,
			clientIDs: make([]string, 0),
		}
	} else {
		s = &Sock{
			file:      "",
			line:      0,
			zType:     t,
			clientIDs: make([]string, 0),
		}
	}
	cFile := C.CString(s.file)
	defer C.free(unsafe.Pointer(cFile))
	s.zsockT = C.zsock_new_checked(C.int(s.zType), cFile, C.size_t(s.line))
	return s
}
func (s *Sock) Connect(endpoint string) error {
	cEndpoint := C.CString(endpoint)
	defer C.free(unsafe.Pointer(cEndpoint))
	rc := C.Sock_connect(s.zsockT, cEndpoint)
	if rc != C.int(0) {
		return ErrConnect
	}
	return nil
}
func (s *Sock) Disconnect(endpoint string) error {
	cEndpoint := C.CString(endpoint)
	defer C.free(unsafe.Pointer(cEndpoint))
	rc := C.Sock_disconnect(s.zsockT, cEndpoint)
	if int(rc) == -1 {
		return ErrDisconnect
	}
	return nil
}
func (s *Sock) Bind(endpoint string) (int, error) {
	cEndpoint := C.CString(endpoint)
	defer C.free(unsafe.Pointer(cEndpoint))
	port := C.Sock_bind(s.zsockT, cEndpoint)
	if port == C.int(-1) {
		return -1, ErrBind
	}
	return int(port), nil
}
func (s *Sock) Unbind(endpoint string) error {
	cEndpoint := C.CString(endpoint)
	defer C.free(unsafe.Pointer(cEndpoint))
	rc := C.Sock_unbind(s.zsockT, cEndpoint)
	if int(rc) == -1 {
		return ErrUnbind
	}
	return nil
}
func (s *Sock) Attach(endpoints string, serverish bool) error {
	cEndpoints := C.CString(endpoints)
	defer C.free(unsafe.Pointer(cEndpoints))
	rc := C.zsock_attach(s.zsockT, cEndpoints, C._Bool(serverish))
	if rc == -1 {
		return ErrSockAttach
	}
	return nil
}
func NewPub(endpoints string) (*Sock, error) {
	s := NewSock(Pub)
	return s, s.Attach(endpoints, true)
}
func NewSub(endpoints string, subscribe string) (*Sock, error) {
	s := NewSock(Sub)
	subscriptions := strings.Split(subscribe, ",")
	for _, topic := range subscriptions {
		s.SetSubscribe(topic)
	}
	return s, s.Attach(endpoints, false)
}