Source file src/syscall/net_wasip1.go

     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  //go:build wasip1
     6  
     7  package syscall
     8  
     9  import "unsafe"
    10  
    11  const (
    12  	SHUT_RD   = 0x1
    13  	SHUT_WR   = 0x2
    14  	SHUT_RDWR = SHUT_RD | SHUT_WR
    15  )
    16  
    17  type sdflags = uint32
    18  
    19  //go:wasmimport wasi_snapshot_preview1 sock_accept
    20  //go:noescape
    21  func sock_accept(fd int32, flags fdflags, newfd unsafe.Pointer) Errno
    22  
    23  //go:wasmimport wasi_snapshot_preview1 sock_shutdown
    24  //go:noescape
    25  func sock_shutdown(fd int32, flags sdflags) Errno
    26  
    27  func Socket(proto, sotype, unused int) (fd int, err error) {
    28  	return 0, ENOSYS
    29  }
    30  
    31  func Bind(fd int, sa Sockaddr) error {
    32  	return ENOSYS
    33  }
    34  
    35  func StopIO(fd int) error {
    36  	return ENOSYS
    37  }
    38  
    39  func Listen(fd int, backlog int) error {
    40  	return ENOSYS
    41  }
    42  
    43  func Accept(fd int) (int, Sockaddr, error) {
    44  	var newfd int32
    45  	errno := sock_accept(int32(fd), 0, unsafe.Pointer(&newfd))
    46  	return int(newfd), nil, errnoErr(errno)
    47  }
    48  
    49  func Connect(fd int, sa Sockaddr) error {
    50  	return ENOSYS
    51  }
    52  
    53  func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
    54  	return 0, nil, ENOSYS
    55  }
    56  
    57  func Sendto(fd int, p []byte, flags int, to Sockaddr) error {
    58  	return ENOSYS
    59  }
    60  
    61  func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn, recvflags int, from Sockaddr, err error) {
    62  	return 0, 0, 0, nil, ENOSYS
    63  }
    64  
    65  func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
    66  	return 0, ENOSYS
    67  }
    68  
    69  func GetsockoptInt(fd, level, opt int) (value int, err error) {
    70  	return 0, ENOSYS
    71  }
    72  
    73  func SetsockoptInt(fd, level, opt int, value int) error {
    74  	return ENOSYS
    75  }
    76  
    77  func SetReadDeadline(fd int, t int64) error {
    78  	return ENOSYS
    79  }
    80  
    81  func SetWriteDeadline(fd int, t int64) error {
    82  	return ENOSYS
    83  }
    84  
    85  func Shutdown(fd int, how int) error {
    86  	errno := sock_shutdown(int32(fd), sdflags(how))
    87  	return errnoErr(errno)
    88  }
    89  

View as plain text