예제 #1
0
파일: goutp.go 프로젝트: utamaro/storjutp-1
//UtpConnect starts to connect
func (s *UtpSocket) UtpConnect(addr *net.UDPAddr) int64 {
	addrinfo := C.getAddrInfo(C.CString(addr.IP.String()), (C.int)(addr.Port))
	size := C.utp_connect(s.s, addrinfo.ai_addr, (C.socklen_t)(addrinfo.ai_addrlen))
	C.freeaddrinfo(addrinfo)
	return (int64)(size)
}
예제 #2
0
파일: goutp.go 프로젝트: utamaro/storjutp-1
//UtpProcessUDP process one udp packet
func (ctx *UtpContext) UtpProcessUDP(buf []byte, addr *net.UDPAddr) int64 {
	addrinfo := C.getAddrInfo(C.CString(addr.IP.String()), (C.int)(addr.Port))
	size := C.utp_process_udp(ctx.ctx, (*C.byte)(&buf[0]), (C.size_t)(len(buf)), addrinfo.ai_addr, (C.socklen_t)(addrinfo.ai_addrlen))
	C.freeaddrinfo(addrinfo)
	return (int64)(size)
}