@@ -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"
|
||||
@@ -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)
|
||||
@@ -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 {
|
||||
Reference in New Issue
Block a user