Ejemplo n.º 1
0
// Recv waits for the specific timeout in milliseconds to receive a beacon
func (b *Beacon) Recv(timeout int) [][]byte {
	C.zsock_set_rcvtimeo(unsafe.Pointer(b.zactorT), C.int(timeout))

	cAddrFrame := C.zframe_recv(unsafe.Pointer(b.zactorT))
	defer C.zframe_destroy(&cAddrFrame)
	if cAddrFrame == nil {
		return nil
	}
	addr := C.GoBytes(unsafe.Pointer(C.zframe_data(cAddrFrame)), C.int(C.zframe_size(cAddrFrame)))

	cBeaconFrame := C.zframe_recv(unsafe.Pointer(b.zactorT))
	defer C.zframe_destroy(&cBeaconFrame)
	if cBeaconFrame == nil {
		return nil
	}
	beacon := C.GoBytes(unsafe.Pointer(C.zframe_data(cBeaconFrame)), C.int(C.zframe_size(cBeaconFrame)))

	return [][]byte{addr, beacon}
}
Ejemplo n.º 2
0
// Recv waits for the specific timeout in milliseconds to receive a beacon
func (b *Beacon) Recv(timeout int) [][]byte {
	C.zsock_set_rcvtimeo(unsafe.Pointer(b.zactorT), C.int(timeout))
	addrStr := C.zstr_recv(unsafe.Pointer(b.zactorT))
	beaconStr := C.zstr_recv(unsafe.Pointer(b.zactorT))
	return [][]byte{[]byte(C.GoString(addrStr)), []byte(C.GoString(beaconStr))}
}
Ejemplo n.º 3
0
// Recv waits for the specific timeout in milliseconds to receive a beacon
func (b *Beacon) Recv(timeout int) string {
	C.zsock_set_rcvtimeo(unsafe.Pointer(b.zactorT), C.int(timeout))
	msg := C.zstr_recv(unsafe.Pointer(b.zactorT))
	return C.GoString(msg)
}
Ejemplo n.º 4
0
// SetRcvtimeo sets the rcvtimeo option for the socket
func (s *Sock) SetRcvtimeo(val int) {
	C.zsock_set_rcvtimeo(unsafe.Pointer(s.zsockT), C.int(val))
}