@@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var hints net.AddrInfo
|
var hints net.AddrInfo
|
||||||
hints.AiFamily = net.AF_UNSPEC
|
hints.Family = net.AF_UNSPEC
|
||||||
hints.AiSockType = net.SOCK_STREAM
|
hints.SockType = net.SOCK_STREAM
|
||||||
|
|
||||||
host := "httpbin.org"
|
host := "httpbin.org"
|
||||||
port := "80"
|
port := "80"
|
||||||
@@ -1,23 +1,21 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/c/os"
|
"github.com/goplus/llgo/c/os"
|
||||||
"github.com/goplus/llgo/c/sys"
|
"github.com/goplus/llgo/c/sys"
|
||||||
"github.com/goplus/llgo/c/syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var readFds syscall.FdSet
|
var readFds sys.FdSet
|
||||||
|
|
||||||
sys.FD_ZERO(&readFds)
|
sys.FD_ZERO(&readFds)
|
||||||
|
|
||||||
sys.FD_SET(0, &readFds)
|
sys.FD_SET(0, &readFds)
|
||||||
|
|
||||||
var tv sys.TimeVal
|
var tv sys.Timeval
|
||||||
tv.TvSec = 5
|
tv.Sec = 5
|
||||||
tv.TvUSec = 0
|
tv.Usec = 0
|
||||||
|
|
||||||
c.Printf(c.Str("Waiting for input on stdin...\n"))
|
c.Printf(c.Str("Waiting for input on stdin...\n"))
|
||||||
ret := sys.Select(1, &readFds, nil, nil, &tv)
|
ret := sys.Select(1, &readFds, nil, nil, &tv)
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
"github.com/goplus/llgo/c"
|
"github.com/goplus/llgo/c"
|
||||||
"github.com/goplus/llgo/c/net"
|
"github.com/goplus/llgo/c/net"
|
||||||
"github.com/goplus/llgo/c/os"
|
"github.com/goplus/llgo/c/os"
|
||||||
"github.com/goplus/llgo/c/sys"
|
"github.com/goplus/llgo/c/sys"
|
||||||
"github.com/goplus/llgo/c/syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -41,14 +41,15 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var writefds, readfds syscall.FdSet
|
var writefds, readfds sys.FdSet
|
||||||
var timeout sys.TimeVal
|
var timeout sys.Timeval
|
||||||
|
|
||||||
// Monitor socket writes
|
// Monitor socket writes
|
||||||
sys.FD_ZERO(&writefds)
|
sys.FD_ZERO(&writefds)
|
||||||
sys.FD_SET(sock, &writefds)
|
sys.FD_SET(sock, &writefds)
|
||||||
timeout.TvSec = 10
|
timeout.Sec = 10
|
||||||
timeout.TvUSec = 0
|
timeout.Usec = 0
|
||||||
|
|
||||||
// Use select to monitor the readiness of writes
|
// Use select to monitor the readiness of writes
|
||||||
if sys.Select(sock+1, nil, &writefds, nil, &timeout) > 0 {
|
if sys.Select(sock+1, nil, &writefds, nil, &timeout) > 0 {
|
||||||
if sys.FD_ISSET(sock, &writefds) != 0 {
|
if sys.FD_ISSET(sock, &writefds) != 0 {
|
||||||
Reference in New Issue
Block a user