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

View as plain text