| 1 |
// Copyright 2023 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 |
// Fake networking for js/wasm and wasip1/wasm. |
| 6 |
|
| 7 |
//go:build js || wasip1 |
| 8 |
|
| 9 |
package syscall |
| 10 |
|
| 11 |
const ( |
| 12 |
AF_UNSPEC = iota |
| 13 |
AF_UNIX |
| 14 |
AF_INET |
| 15 |
AF_INET6 |
| 16 |
) |
| 17 |
|
| 18 |
const ( |
| 19 |
SOCK_STREAM = 1 + iota |
| 20 |
SOCK_DGRAM |
| 21 |
SOCK_RAW |
| 22 |
SOCK_SEQPACKET |
| 23 |
) |
| 24 |
|
| 25 |
const ( |
| 26 |
IPPROTO_IP = 0 |
| 27 |
IPPROTO_IPV4 = 4 |
| 28 |
IPPROTO_IPV6 = 0x29 |
| 29 |
IPPROTO_TCP = 6 |
| 30 |
IPPROTO_UDP = 0x11 |
| 31 |
) |
| 32 |
|
| 33 |
const ( |
| 34 |
SOMAXCONN = 0x80 |
| 35 |
) |
| 36 |
|
| 37 |
const ( |
| 38 |
_ = iota |
| 39 |
IPV6_V6ONLY |
| 40 |
SO_ERROR |
| 41 |
) |
| 42 |
|
| 43 |
// Misc constants expected by package net but not supported. |
| 44 |
const ( |
| 45 |
_ = iota |
| 46 |
F_DUPFD_CLOEXEC |
| 47 |
SYS_FCNTL = 500 // unsupported |
| 48 |
) |
| 49 |
|
| 50 |
type Sockaddr any |
| 51 |
|
| 52 |
type SockaddrInet4 struct { |
| 53 |
Port int |
| 54 |
Addr [4]byte |
| 55 |
} |
| 56 |
|
| 57 |
type SockaddrInet6 struct { |
| 58 |
Port int |
| 59 |
ZoneId uint32 |
| 60 |
Addr [16]byte |
| 61 |
} |
| 62 |
|
| 63 |
type SockaddrUnix struct { |
| 64 |
Name string |
| 65 |
} |