本文整理匯總了Golang中C.zmq_getsockopt函數的典型用法代碼示例。如果您正苦於以下問題:Golang zmq_getsockopt函數的具體用法?Golang zmq_getsockopt怎麽用?Golang zmq_getsockopt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了zmq_getsockopt函數的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetSockOptBool
func (s *zmqSocket) GetSockOptBool(option BoolSocketOption) (value bool, err error) {
size := C.size_t(unsafe.Sizeof(value))
if C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&value), &size) != 0 {
err = errno()
return
}
return
}
示例2: GetFd
/*
ZMQ_FD: Retrieve file descriptor associated with the socket
See: http://api.zeromq.org/4-1:zmq-getsockopt#toc9
*/
func (soc *Socket) GetFd() (uintptr, error) {
value := C.SOCKET(0)
size := C.size_t(unsafe.Sizeof(value))
if i, err := C.zmq_getsockopt(soc.soc, C.ZMQ_FD, unsafe.Pointer(&value), &size); i != 0 {
return uintptr(0), errget(err)
}
return uintptr(value), nil
}
示例3: getUInt64
func (soc *Socket) getUInt64(opt C.int) (uint64, error) {
value := C.uint64_t(0)
size := C.size_t(unsafe.Sizeof(value))
if i, err := C.zmq_getsockopt(soc.soc, opt, unsafe.Pointer(&value), &size); i != 0 {
return 0, errget(err)
}
return uint64(value), nil
}
示例4: getString
func (soc *Socket) getString(opt C.int, bufsize int) (string, error) {
value := make([]byte, bufsize)
size := C.size_t(bufsize)
if i, err := C.zmq_getsockopt(soc.soc, opt, unsafe.Pointer(&value[0]), &size); i != 0 {
return "", errget(err)
}
return string(value[:int(size)]), nil
}
示例5: GetSockOptUInt64
// Get a uint64 option from the socket.
// int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
func (s *zmqSocket) GetSockOptUInt64(option UInt64SocketOption) (value uint64, err os.Error) {
size := C.size_t(unsafe.Sizeof(value))
if C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&value), &size) != 0 {
err = errno()
return
}
return
}
示例6: GetSockOptBool
func (s *Socket) GetSockOptBool(option BoolSocketOption) (value bool, err error) {
size := C.size_t(unsafe.Sizeof(value))
var rc C.int
if rc, err = C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&value), &size); rc != 0 {
err = casterr(err)
return
}
return
}
示例7: GetSockOptUInt64
// Get a uint64 option from the socket.
// int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
func (s *Socket) GetSockOptUInt64(option UInt64SocketOption) (value uint64, err error) {
size := C.size_t(unsafe.Sizeof(value))
var rc C.int
if rc, err = C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&value), &size); rc != 0 {
println("GetSockOptUInt64:", err.Error())
err = casterr(err)
return
}
return
}
示例8: GetSockOptString
// Get a string option from the socket.
// int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
func (s *zmqSocket) GetSockOptString(option StringSocketOption) (value string, err error) {
var buffer [1024]byte
var size C.size_t = 1024
if C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&buffer), &size) != 0 {
err = errno()
return
}
value = string(buffer[:size])
return
}
示例9: getUInt32
func (soc *Socket) getUInt32(opt C.int) (uint32, error) {
if !soc.opened {
return 0, ErrorSocketClosed
}
value := C.uint32_t(0)
size := C.size_t(unsafe.Sizeof(value))
if i, err := C.zmq_getsockopt(soc.soc, opt, unsafe.Pointer(&value), &size); i != 0 {
return 0, errget(err)
}
return uint32(value), nil
}
示例10: getString
func (soc *Socket) getString(opt C.int, bufsize int) (string, error) {
if !soc.opened {
return "", ErrorSocketClosed
}
value := make([]byte, bufsize)
size := C.size_t(bufsize)
if i, err := C.zmq_getsockopt(soc.soc, opt, unsafe.Pointer(&value[0]), &size); i != 0 {
return "", errget(err)
}
return strings.TrimRight(string(value[:int(size)]), "\x00"), nil
}
示例11: GetSockOptString
// Get a string option from the socket.
// int zmq_getsockopt (void *s, int option, void *optval, size_t *optvallen);
func (s *Socket) GetSockOptString(option StringSocketOption) (value string, err error) {
var buffer [1024]byte
var size C.size_t = 1024
var rc C.int
if rc, err = C.zmq_getsockopt(s.s, C.int(option), unsafe.Pointer(&buffer), &size); rc != 0 {
err = casterr(err)
return
}
value = string(buffer[:size])
return
}