| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/listdial.R |
| 3 |
\name{dial} |
| 4 |
\alias{dial} |
| 5 |
\title{Dial an Address from a Socket} |
| 6 |
\usage{ |
| 7 |
dial( |
| 8 |
socket, |
| 9 |
url = "inproc://nanonext", |
| 10 |
tls = NULL, |
| 11 |
autostart = TRUE, |
| 12 |
fail = c("warn", "error", "none") |
| 13 |
) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{socket}{a Socket.} |
| 17 |
|
| 18 |
\item{url}{[default 'inproc://nanonext'] a URL to dial, specifying the |
| 19 |
transport and address as a character string e.g. 'inproc://anyvalue' or |
| 20 |
'tcp://127.0.0.1:5555' (see \link{transports}).} |
| 21 |
|
| 22 |
\item{tls}{[default NULL] for secure tls+tcp:// or wss:// connections only, |
| 23 |
provide a TLS configuration object created by \code{\link[=tls_config]{tls_config()}}.} |
| 24 |
|
| 25 |
\item{autostart}{[default TRUE] whether to start the dialer (by default |
| 26 |
asynchronously). Set to NA to start synchronously - this is less resilient |
| 27 |
if a connection is not immediately possible, but avoids subtle errors from |
| 28 |
attempting to use the socket before an asynchronous dial has completed. Set |
| 29 |
to FALSE if setting configuration options on the dialer as it is not |
| 30 |
generally possible to change these once started.} |
| 31 |
|
| 32 |
\item{fail}{[default 'warn'] failure mode - a character value or integer |
| 33 |
equivalent, whether to warn (1L), error (2L), or for none (3L) just return |
| 34 |
an 'errorValue' without any corresponding warning.} |
| 35 |
} |
| 36 |
\value{ |
| 37 |
Invisibly, an integer exit code (zero on success). A new Dialer |
| 38 |
(object of class 'nanoDialer' and 'nano') is created and bound to the |
| 39 |
Socket if successful. |
| 40 |
} |
| 41 |
\description{ |
| 42 |
Creates a new Dialer and binds it to a Socket. |
| 43 |
} |
| 44 |
\details{ |
| 45 |
To view all Dialers bound to a socket use \verb{$dialer} on the socket, which |
| 46 |
returns a list of Dialer objects. To access any individual Dialer (e.g. to |
| 47 |
set options on it), index into the list e.g. \verb{$dialer[[1]]} to return the |
| 48 |
first Dialer. |
| 49 |
|
| 50 |
A Dialer is an external pointer to a dialer object, which creates a single |
| 51 |
outgoing connection at a time. If the connection is broken, or fails, the |
| 52 |
dialer object will automatically attempt to reconnect, and will keep doing so |
| 53 |
until the dialer or socket is destroyed. |
| 54 |
} |
| 55 |
\section{Further details}{ |
| 56 |
|
| 57 |
|
| 58 |
Dialers and Listeners are always associated with a single socket. A given |
| 59 |
socket may have multiple Listeners and/or multiple Dialers. |
| 60 |
|
| 61 |
The client/server relationship described by dialer/listener is completely |
| 62 |
orthogonal to any similar relationship in the protocols. For example, a rep |
| 63 |
socket may use a dialer to connect to a listener on an req socket. This |
| 64 |
orthogonality can lead to innovative solutions to otherwise challenging |
| 65 |
communications problems. |
| 66 |
|
| 67 |
Any configuration options on the dialer/listener should be set by \code{\link[=opt<-]{opt<-()}} |
| 68 |
before starting the dialer/listener with \code{\link[=start]{start()}}. |
| 69 |
|
| 70 |
Dialers/Listeners may be destroyed by \code{\link[=close]{close()}}. They are also closed when |
| 71 |
their associated socket is closed. |
| 72 |
} |
| 73 |
|
| 74 |
\examples{ |
| 75 |
socket <- socket("rep") |
| 76 |
dial(socket, url = "inproc://nanodial", autostart = FALSE) |
| 77 |
socket$dialer |
| 78 |
start(socket$dialer[[1]]) |
| 79 |
socket$dialer |
| 80 |
close(socket$dialer[[1]]) |
| 81 |
close(socket) |
| 82 |
|
| 83 |
nano <- nano("bus") |
| 84 |
nano$dial(url = "inproc://nanodial", autostart = FALSE) |
| 85 |
nano$dialer |
| 86 |
nano$dialer_start() |
| 87 |
nano$dialer |
| 88 |
close(nano$dialer[[1]]) |
| 89 |
nano$close() |
| 90 |
|
| 91 |
} |