Example #1
0
func (s *Socket) SetSockOptInt(level, option C.int, value int) error {
	val := C.int(value)
	length := C.size_t(unsafe.Sizeof(val))
	rc, err := C.nn_setsockopt(s.socket, level, option, unsafe.Pointer(&val), length)
	if rc != 0 {
		return nnError(err)
	}
	return nil
}
Example #2
0
// SetSockOptString sets the value of the option.
func (s *Socket) SetSockOptString(level, option C.int, value string) error {
	cstr := C.CString(value)
	defer C.free(unsafe.Pointer(cstr))
	length := C.size_t(len(value))
	rc, err := C.nn_setsockopt(s.socket, level, option, unsafe.Pointer(cstr), length)
	if rc != 0 {
		return nnError(err)
	}
	return nil
}