1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build wasip1
package syscall
import "unsafe"
const (
SHUT_RD = 0x1
SHUT_WR = 0x2
SHUT_RDWR = SHUT_RD | SHUT_WR
)
type sdflags = uint32
//go:wasmimport wasi_snapshot_preview1 sock_accept
//go:noescape
func sock_accept(fd int32, flags fdflags, newfd unsafe.Pointer) Errno
//go:wasmimport wasi_snapshot_preview1 sock_shutdown
//go:noescape
func sock_shutdown(fd int32, flags sdflags) Errno
func Socket(proto, sotype, unused int) (fd int, err error) {
return 0, ENOSYS
}
func Bind(fd int, sa Sockaddr) error {
return ENOSYS
}
func StopIO(fd int) error {
return ENOSYS
}
func Listen(fd int, backlog int) error {
return ENOSYS
}
func Accept(fd int) (int, Sockaddr, error) {
var newfd int32
errno := sock_accept(int32(fd), 0, unsafe.Pointer(&newfd))
return int(newfd), nil, errnoErr(errno)
}
func Connect(fd int, sa Sockaddr) error {
return ENOSYS
}
func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
return 0, nil, ENOSYS
}
func Sendto(fd int, p []byte, flags int, to Sockaddr) error {
return ENOSYS
}
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn, recvflags int, from Sockaddr, err error) {
return 0, 0, 0, nil, ENOSYS
}
func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
return 0, ENOSYS
}
func GetsockoptInt(fd, level, opt int) (value int, err error) {
return 0, ENOSYS
}
func SetsockoptInt(fd, level, opt int, value int) error {
return ENOSYS
}
func SetReadDeadline(fd int, t int64) error {
return ENOSYS
}
func SetWriteDeadline(fd int, t int64) error {
return ENOSYS
}
func Shutdown(fd int, how int) error {
errno := sock_shutdown(int32(fd), sdflags(how))
return errnoErr(errno)
}
|