github.com/code-reading/golang@v0.0.0-20220303082512-ba5bc0e589a3/go/src/syscall/net_js.go (about) 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 //go:build js && wasm 9 // +build js,wasm 10 11 package syscall 12 13 const ( 14 AF_UNSPEC = iota 15 AF_UNIX 16 AF_INET 17 AF_INET6 18 ) 19 20 const ( 21 SOCK_STREAM = 1 + iota 22 SOCK_DGRAM 23 SOCK_RAW 24 SOCK_SEQPACKET 25 ) 26 27 const ( 28 IPPROTO_IP = 0 29 IPPROTO_IPV4 = 4 30 IPPROTO_IPV6 = 0x29 31 IPPROTO_TCP = 6 32 IPPROTO_UDP = 0x11 33 ) 34 35 const ( 36 _ = iota 37 IPV6_V6ONLY 38 SOMAXCONN 39 SO_ERROR 40 ) 41 42 // Misc constants expected by package net but not supported. 43 const ( 44 _ = iota 45 F_DUPFD_CLOEXEC 46 SYS_FCNTL = 500 // unsupported 47 ) 48 49 type Sockaddr interface { 50 } 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 } 66 67 func Socket(proto, sotype, unused int) (fd int, err error) { 68 return 0, ENOSYS 69 } 70 71 func Bind(fd int, sa Sockaddr) error { 72 return ENOSYS 73 } 74 75 func StopIO(fd int) error { 76 return ENOSYS 77 } 78 79 func Listen(fd int, backlog int) error { 80 return ENOSYS 81 } 82 83 func Accept(fd int) (newfd int, sa Sockaddr, err error) { 84 return 0, nil, ENOSYS 85 } 86 87 func Connect(fd int, sa Sockaddr) error { 88 return ENOSYS 89 } 90 91 func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) { 92 return 0, nil, ENOSYS 93 } 94 95 func Sendto(fd int, p []byte, flags int, to Sockaddr) error { 96 return ENOSYS 97 } 98 99 func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn, recvflags int, from Sockaddr, err error) { 100 return 0, 0, 0, nil, ENOSYS 101 } 102 103 func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { 104 return 0, ENOSYS 105 } 106 107 func GetsockoptInt(fd, level, opt int) (value int, err error) { 108 return 0, ENOSYS 109 } 110 111 func SetsockoptInt(fd, level, opt int, value int) error { 112 return nil 113 } 114 115 func SetReadDeadline(fd int, t int64) error { 116 return ENOSYS 117 } 118 119 func SetWriteDeadline(fd int, t int64) error { 120 return ENOSYS 121 } 122 123 func Shutdown(fd int, how int) error { 124 return ENOSYS 125 } 126 127 func SetNonblock(fd int, nonblocking bool) error { 128 return nil 129 }