Learn R Programming

nanonext (version 0.5.1)

setopt: Set Option on Socket, Context, Dialer, Listener or Stream

Description

Set opts on a Socket, Context, Dialer, Listener or Stream.

Usage

setopt(
  object,
  type = c("bool", "int", "ms", "size", "string", "uint64"),
  opt,
  value
)

# S3 method for nanoSocket setopt( object, type = c("bool", "int", "ms", "size", "string", "uint64"), opt, value )

# S3 method for nanoContext setopt( object, type = c("bool", "int", "ms", "size", "string", "uint64"), opt, value )

# S3 method for nanoDialer setopt( object, type = c("bool", "int", "ms", "size", "string", "uint64"), opt, value )

# S3 method for nanoListener setopt( object, type = c("bool", "int", "ms", "size", "string", "uint64"), opt, value )

# S3 method for nanoStream setopt( object, type = c("bool", "int", "ms", "size", "string", "uint64"), opt, value )

Arguments

object

a Socket, Context, Listener, Dialer or Stream.

type

[default 'bool'] type of option - either 'bool', 'int', 'ms' (duration), 'size', 'string' or 'uint64'.

opt

name of option, e.g. 'reconnect-time-min', as a character string. See opts.

value

value of option.

Value

Invisibly, an integer exit code (zero on success).

Details

Note: once a dialer or listener has started, it is not generally possible to change its configuration. Hence create the dialer or listener with 'autostart = FALSE' if configuration needs to be set.

To set options on a Listener or Dialer attached to a Socket or nano object, you must pass in the objects directly via for example $listener[[1]] for the first Listener.

Examples

Run this code
# NOT RUN {
s <- socket("pair")
setopt(s, "ms", "recv-timeout", 2000)
close(s)

s <- socket("req")
ctx <- context(s)
setopt(ctx, "ms", "send-timeout", 2000)
close(ctx)
close(s)

s <- socket("pair", dial = "inproc://nanonext", autostart = FALSE)
setopt(s$dialer[[1]], "ms", "reconnect-time-min", 2000)
start(s$dialer[[1]])
close(s)

s <- socket("pair", listen = "inproc://nanonext", autostart = FALSE)
setopt(s$listener[[1]], "size", "recv-size-max", 1024)
start(s$listener[[1]])
close(s)

# }

Run the code above in your browser using DataLab