1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// js/wasm uses fake networking directly implemented in the net package.
6// This file only exists to make the compiler happy.
7
8// +build js,wasm
9
10package syscall
11
12const (
13	AF_UNSPEC = iota
14	AF_UNIX
15	AF_INET
16	AF_INET6
17)
18
19const (
20	SOCK_STREAM = 1 + iota
21	SOCK_DGRAM
22	SOCK_RAW
23	SOCK_SEQPACKET
24)
25
26const (
27	IPPROTO_IP   = 0
28	IPPROTO_IPV4 = 4
29	IPPROTO_IPV6 = 0x29
30	IPPROTO_TCP  = 6
31	IPPROTO_UDP  = 0x11
32)
33
34const (
35	_ = iota
36	IPV6_V6ONLY
37	SOMAXCONN
38	SO_ERROR
39)
40
41// Misc constants expected by package net but not supported.
42const (
43	_ = iota
44	F_DUPFD_CLOEXEC
45	SYS_FCNTL = 500 // unsupported
46)
47
48type Sockaddr interface {
49}
50
51type SockaddrInet4 struct {
52	Port int
53	Addr [4]byte
54}
55
56type SockaddrInet6 struct {
57	Port   int
58	ZoneId uint32
59	Addr   [16]byte
60}
61
62type SockaddrUnix struct {
63	Name string
64}
65
66func Socket(proto, sotype, unused int) (fd int, err error) {
67	return 0, ENOSYS
68}
69
70func Bind(fd int, sa Sockaddr) error {
71	return ENOSYS
72}
73
74func StopIO(fd int) error {
75	return ENOSYS
76}
77
78func Listen(fd int, backlog int) error {
79	return ENOSYS
80}
81
82func Accept(fd int) (newfd int, sa Sockaddr, err error) {
83	return 0, nil, ENOSYS
84}
85
86func Connect(fd int, sa Sockaddr) error {
87	return ENOSYS
88}
89
90func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
91	return 0, nil, ENOSYS
92}
93
94func Sendto(fd int, p []byte, flags int, to Sockaddr) error {
95	return ENOSYS
96}
97
98func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn, recvflags int, from Sockaddr, err error) {
99	return 0, 0, 0, nil, ENOSYS
100}
101
102func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
103	return 0, ENOSYS
104}
105
106func GetsockoptInt(fd, level, opt int) (value int, err error) {
107	return 0, ENOSYS
108}
109
110func SetsockoptInt(fd, level, opt int, value int) error {
111	return nil
112}
113
114func SetReadDeadline(fd int, t int64) error {
115	return ENOSYS
116}
117
118func SetWriteDeadline(fd int, t int64) error {
119	return ENOSYS
120}
121
122func Shutdown(fd int, how int) error {
123	return ENOSYS
124}
125
126func SetNonblock(fd int, nonblocking bool) error {
127	return nil
128}
129