...
Run Format

Source file src/syscall/net_js.go

Documentation: syscall

     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  
    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; same value as net_nacl.go
    46  )
    47  
    48  type Sockaddr interface {
    49  }
    50  
    51  type SockaddrInet4 struct {
    52  	Port int
    53  	Addr [4]byte
    54  }
    55  
    56  type SockaddrInet6 struct {
    57  	Port   int
    58  	ZoneId uint32
    59  	Addr   [16]byte
    60  }
    61  
    62  type SockaddrUnix struct {
    63  	Name string
    64  }
    65  
    66  func Socket(proto, sotype, unused int) (fd int, err error) {
    67  	return 0, ENOSYS
    68  }
    69  
    70  func Bind(fd int, sa Sockaddr) error {
    71  	return ENOSYS
    72  }
    73  
    74  func StopIO(fd int) error {
    75  	return ENOSYS
    76  }
    77  
    78  func Listen(fd int, backlog int) error {
    79  	return ENOSYS
    80  }
    81  
    82  func Accept(fd int) (newfd int, sa Sockaddr, err error) {
    83  	return 0, nil, ENOSYS
    84  }
    85  
    86  func Connect(fd int, sa Sockaddr) error {
    87  	return ENOSYS
    88  }
    89  
    90  func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
    91  	return 0, nil, ENOSYS
    92  }
    93  
    94  func Sendto(fd int, p []byte, flags int, to Sockaddr) error {
    95  	return ENOSYS
    96  }
    97  
    98  func 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  
   102  func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
   103  	return 0, ENOSYS
   104  }
   105  
   106  func GetsockoptInt(fd, level, opt int) (value int, err error) {
   107  	return 0, ENOSYS
   108  }
   109  
   110  func SetsockoptInt(fd, level, opt int, value int) error {
   111  	return nil
   112  }
   113  
   114  func SetReadDeadline(fd int, t int64) error {
   115  	return ENOSYS
   116  }
   117  
   118  func SetWriteDeadline(fd int, t int64) error {
   119  	return ENOSYS
   120  }
   121  
   122  func Shutdown(fd int, how int) error {
   123  	return ENOSYS
   124  }
   125  
   126  func SetNonblock(fd int, nonblocking bool) error {
   127  	return nil
   128  }
   129  

View as plain text