Socket.Port (socket2 v2.1.1)
This module wraps local running program using Port
.
Options
When creating a socket you can pass a series of options to use for it.
:as
sets the kind of value returned by recv, either:binary
or:list
, the default is:binary
:packet
seeinet:setopts
:size
sets the max length of the packet body, seeinet:setopts
:env
provides 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)
Create a Port based on the given command.
open(cmd, options)
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.