diff --git a/_demo/netdb/netdb.go b/_demo/netdbdemo/netdb.go similarity index 82% rename from _demo/netdb/netdb.go rename to _demo/netdbdemo/netdb.go index 879ba3e8..f8da4aa0 100644 --- a/_demo/netdb/netdb.go +++ b/_demo/netdbdemo/netdb.go @@ -7,8 +7,8 @@ import ( func main() { var hints net.AddrInfo - hints.AiFamily = net.AF_UNSPEC - hints.AiSockType = net.SOCK_STREAM + hints.Family = net.AF_UNSPEC + hints.SockType = net.SOCK_STREAM host := "httpbin.org" port := "80" diff --git a/_demo/select/select.go b/c/sys/_demo/selectdemo/select.go similarity index 87% rename from _demo/select/select.go rename to c/sys/_demo/selectdemo/select.go index 918150f8..eaff1c80 100644 --- a/_demo/select/select.go +++ b/c/sys/_demo/selectdemo/select.go @@ -1,23 +1,21 @@ package main import ( + "unsafe" + "github.com/goplus/llgo/c" "github.com/goplus/llgo/c/os" "github.com/goplus/llgo/c/sys" - "github.com/goplus/llgo/c/syscall" - "unsafe" ) func main() { - var readFds syscall.FdSet - + var readFds sys.FdSet sys.FD_ZERO(&readFds) - sys.FD_SET(0, &readFds) - var tv sys.TimeVal - tv.TvSec = 5 - tv.TvUSec = 0 + var tv sys.Timeval + tv.Sec = 5 + tv.Usec = 0 c.Printf(c.Str("Waiting for input on stdin...\n")) ret := sys.Select(1, &readFds, nil, nil, &tv) diff --git a/_demo/select/select2.go b/c/sys/_demo/selectdemo2/select2.go similarity index 93% rename from _demo/select/select2.go rename to c/sys/_demo/selectdemo2/select2.go index 68069d1e..ada4418a 100644 --- a/_demo/select/select2.go +++ b/c/sys/_demo/selectdemo2/select2.go @@ -1,12 +1,12 @@ package main import ( + "unsafe" + "github.com/goplus/llgo/c" "github.com/goplus/llgo/c/net" "github.com/goplus/llgo/c/os" "github.com/goplus/llgo/c/sys" - "github.com/goplus/llgo/c/syscall" - "unsafe" ) const ( @@ -41,14 +41,15 @@ func main() { return } - var writefds, readfds syscall.FdSet - var timeout sys.TimeVal + var writefds, readfds sys.FdSet + var timeout sys.Timeval // Monitor socket writes sys.FD_ZERO(&writefds) sys.FD_SET(sock, &writefds) - timeout.TvSec = 10 - timeout.TvUSec = 0 + timeout.Sec = 10 + timeout.Usec = 0 + // Use select to monitor the readiness of writes if sys.Select(sock+1, nil, &writefds, nil, &timeout) > 0 { if sys.FD_ISSET(sock, &writefds) != 0 {