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