Socket type-independent wrapper functions for getsockopt(2)
and setsockopt(2)
system calls for internal net
package use.
primitive val _OSSocket
new val create() : _OSSocket val^
Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_ERROR, ...)
fun box get_so_error( fd: U32 val) : (U32 val , U32 val)
Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...)
fun box get_so_rcvbuf( fd: U32 val) : (U32 val , U32 val)
Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_SNDBUF, ...)
fun box get_so_sndbuf( fd: U32 val) : (U32 val , U32 val)
Wrapper for the FFI call setsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...)
fun box set_so_rcvbuf( fd: U32 val, bufsize: U32 val) : U32 val
Wrapper for the FFI call setsockopt(fd, SOL_SOCKET, SO_SNDBUF, ...)
fun box set_so_sndbuf( fd: U32 val, bufsize: U32 val) : U32 val
General wrapper for sockets to the getsockopt(2)
system call.
The option_max_size
argument is the maximum number of bytes that the caller expects the kernel to return via the system call's void *
4th argument. This function will allocate a Pony Array[U8]
array of size option_max_size
prior to calling getsockopt(2)
.
In case of system call success, this function returns the 2-tuple: 1. The integer 0
. 2. An Array[U8]
of data returned by the system call's void *
4th argument. Its size is specified by the kernel via the system call's sockopt_len_t *
5th argument.
In case of system call failure, this function returns the 2-tuple: 1. The value of errno
. 2. An undefined value that must be ignored.
fun box getsockopt( fd: U32 val, level: I32 val, option_name: I32 val, option_max_size: USize val = 4) : (U32 val , Array[U8 val] iso^)
Wrapper for sockets to the getsockopt(2)
system call where the kernel's returned option value is a C uint32_t
type / Pony type U32
.
In case of system call success, this function returns the 2-tuple: 1. The integer 0
. 2. The *option_value
returned by the kernel converted to a Pony U32
.
In case of system call failure, this function returns the 2-tuple: 1. The value of errno
. 2. An undefined value that must be ignored.
fun box getsockopt_u32( fd: U32 val, level: I32 val, option_name: I32 val) : (U32 val , U32 val)
General wrapper for sockets to the setsockopt(2)
system call.
The caller is responsible for the correct size and byte contents of the option
array for the requested level
and option_name
, including using the appropriate CPU endian byte order.
This function returns 0
on success, else the value of errno
on failure.
fun box setsockopt( fd: U32 val, level: I32 val, option_name: I32 val, option: Array[U8 val] ref) : U32 val
Wrapper for sockets to the setsockopt(2)
system call where the kernel expects an option value of a C uint32_t
type / Pony type U32
.
This function returns 0
on success, else the value of errno
on failure.
fun box setsockopt_u32( fd: U32 val, level: I32 val, option_name: I32 val, option: U32 val) : U32 val
Low-level interface to getsockopt(2)
.
In case of system call success, this function returns the 2-tuple: 1. The integer 0
. 2. An Array[U8]
of data returned by the system call's void *
4th argument. Its size is specified by the kernel via the system call's sockopt_len_t *
5th argument.
In case of system call failure, errno
is returned in the first element of the 2-tuple, and the second element's value is junk.
fun box get_so( fd: U32 val, level: I32 val, option_name: I32 val, option_max_size: USize val) : (U32 val , Array[U8 val] iso^)
fun box set_so( fd: U32 val, level: I32 val, option_name: I32 val, option: Array[U8 val] ref) : U32 val
fun box bytes4_to_u32( b: Array[U8 val] ref) : U32 val ?
fun box u32_to_bytes4( option: U32 val) : Array[U8 val] ref
fun box eq( that: _OSSocket val) : Bool val
fun box ne( that: _OSSocket val) : Bool val
© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/net-_OSSocket