[go-nuts] Re: Cgo: using syscall.Select

2018-05-19 Thread Sergey Kamardin
There are methods which are using raw file descriptors (such 
that https://godoc.org/github.com/mailru/easygo/netpoll#NewDesc).

суббота, 19 мая 2018 г., 2:52:27 UTC+3 пользователь Juliusz Chroboczek 
написал:
>
> > You could also take a look 
> > at https://godoc.org/github.com/mailru/easygo/netpoll 
>
> I don't have a net.Conn, just a raw file descriptor. 
>
> -- Juliusz 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Cgo: using syscall.Select

2018-05-18 Thread Juliusz Chroboczek
> You could also take a look 
> at https://godoc.org/github.com/mailru/easygo/netpoll

I don't have a net.Conn, just a raw file descriptor.

-- Juliusz

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Cgo: using syscall.Select

2018-05-17 Thread Сергей Камардин
You could also take a look 
at https://godoc.org/github.com/mailru/easygo/netpoll

четверг, 17 мая 2018 г., 3:08:29 UTC+3 пользователь Juliusz Chroboczek 
написал:
>
> I'm interfacing with a C library that expects to do its own I/O, but 
> wants to be called after a file descriptor is ready for read.  My code 
> currently looks roughly like this: 
>
> var fdset syscall.FdSet 
> var bits = unsafe.Sizeof(fdset.Bits[0]) * 8 
> fdset.Bits[uintptr(fd)/bits] |= (1 << (fd % bits)) 
> var ctv C.struct_timeval 
> C.gettimeout() 
> tv := syscall.Timeval{int64(ctv.tv_sec), int64(ctv.tv_usec)} 
> n, err := syscall.Select(int(fd + 1), , nil, nil, ) 
> if n < 0 { 
> return err 
> } 
> rc, err := C.dostuff(fd) 
> if(rc < 0) { 
> return err 
> } 
>
> I'm bothered by two things: 
>
>   - the way I access the syscall.FdSet feels like an unportable hack; 
>   - I'd much rather hook into Go's scheduler then burn a thread on 
> sleeping in select. 
>
> Is the above the correct way to interface with the C library, or is 
> there a better way? 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.