Skip to content

_OSSocket

[Source]

Socket type-independent wrapper functions for getsockopt(2) and setsockopt(2) system calls for internal net package use.

primitive val _OSSocket

Constructors

create

[Source]

new val create()
: _OSSocket val^

Returns


Public Functions

get_so_error

[Source]

Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_ERROR, ...)

fun box get_so_error(
  fd: U32 val)
: (U32 val , U32 val)

Parameters

Returns


get_so_rcvbuf

[Source]

Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...)

fun box get_so_rcvbuf(
  fd: U32 val)
: (U32 val , U32 val)

Parameters

Returns


get_so_sndbuf

[Source]

Wrapper for the FFI call getsockopt(fd, SOL_SOCKET, SO_SNDBUF, ...)

fun box get_so_sndbuf(
  fd: U32 val)
: (U32 val , U32 val)

Parameters

Returns


set_so_rcvbuf

[Source]

Wrapper for the FFI call setsockopt(fd, SOL_SOCKET, SO_RCVBUF, ...)

fun box set_so_rcvbuf(
  fd: U32 val,
  bufsize: U32 val)
: U32 val

Parameters

  • fd: U32 val
  • bufsize: U32 val

Returns


set_so_sndbuf

[Source]

Wrapper for the FFI call setsockopt(fd, SOL_SOCKET, SO_SNDBUF, ...)

fun box set_so_sndbuf(
  fd: U32 val,
  bufsize: U32 val)
: U32 val

Parameters

  • fd: U32 val
  • bufsize: U32 val

Returns


getsockopt

[Source]

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 = seq)
: (U32 val , Array[U8 val] iso^)

Parameters

  • fd: U32 val
  • level: I32 val
  • option_name: I32 val
  • option_max_size: USize val = seq

Returns


getsockopt_u32

[Source]

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)

Parameters

  • fd: U32 val
  • level: I32 val
  • option_name: I32 val

Returns


setsockopt

[Source]

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

Parameters

Returns


setsockopt_u32

[Source]

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

Parameters

  • fd: U32 val
  • level: I32 val
  • option_name: I32 val
  • option: U32 val

Returns


get_so

[Source]

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^)

Parameters

  • fd: U32 val
  • level: I32 val
  • option_name: I32 val
  • option_max_size: USize val

Returns


set_so

[Source]

fun box set_so(
  fd: U32 val,
  level: I32 val,
  option_name: I32 val,
  option: Array[U8 val] ref)
: U32 val

Parameters

Returns


bytes4_to_u32

[Source]

fun box bytes4_to_u32(
  b: Array[U8 val] ref)
: U32 val ?

Parameters

Returns


u32_to_bytes4

[Source]

fun box u32_to_bytes4(
  option: U32 val)
: Array[U8 val] ref

Parameters

  • option: U32 val

Returns


eq

[Source]

fun box eq(
  that: _OSSocket val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: _OSSocket val)
: Bool val

Parameters

Returns