Socket.Port (socket2 v2.1.2)
This module wraps local running program using Port.
Options
When creating a socket you can pass a series of options to use for it.
:assets the kind of value returned by recv, either:binaryor:list, the default is:binary:packetseeinet:setopts:sizesets the max length of the packet body, seeinet:setopts:envprovides a map of environment variables for the subprocess
Examples
client = Socket.Port.open!("cat", packet: :line)
client |> Socket.Stream.send!("hi!")
client |> Socket.Stream.recv!()
client |> Socket.Stream.close()
Summary
Functions
Convert Port options to :erlang.open_port compatible arguments.
Return a proper error string for the given code or nil if it can't be converted.
Create a Port based on the given command.
Create a Port based on the given command, raising if an error occurs.
Create a Port based on the given command and options, raising if an error occurs.
Types
@opaque t()
Functions
arguments(options)
Convert Port options to :erlang.open_port compatible arguments.
error(code)
Return a proper error string for the given code or nil if it can't be converted.
open(cmd)
@spec open(binary() | list()) :: {:ok, t()} | {:error, Socket.Error.t()}
Create a Port based on the given command.
open(cmd, options)
@spec open(binary() | list(), Keyword.t()) :: {:ok, t()} | {:error, Socket.Error.t()}
open!(cmd)
Create a Port based on the given command, raising if an error occurs.
open!(cmd, options)
Create a Port based on the given command and options, raising if an error occurs.