| 1 | #' Form an Address/Endpoint |
| 2 | #' |
| 3 | #' A notationally convenient function for forming addresses/endpoints. |
| 4 | #' It's a simple wrapper around the \code{paste0()} function. |
| 5 | #' |
| 6 | #' @param host |
| 7 | #' The host ip address or url. |
| 8 | #' @param port |
| 9 | #' A port; necessary for all transports except ipc. |
| 10 | #' @param transport |
| 11 | #' The transport protocol. Choices are "inproc", "ipc", "tcp", and |
| 12 | #' "pgm"/"epgm" for local in-process (inter-thread), local |
| 13 | #' inter-process, tcp, and pgm, respectively. |
| 14 | #' |
| 15 | #' @return |
| 16 | #' An address, for use with pbdZMQ functions. |
| 17 | #' |
| 18 | #' @author Drew Schmidt |
| 19 | #' |
| 20 | #' @examples |
| 21 | #' address("localhost", 55555) |
| 22 | #' |
| 23 | #' @seealso |
| 24 | #' \code{\link{zmq.bind}} |
| 25 | #' |
| 26 | #' @export |
| 27 | address <- function(host, port, transport="tcp") |
| 28 | { |
| 29 | transports <- c("tcp", "inproc", "ipc", "pgm", "epgm") |
| 30 | transport <- tolower(transport) |
| 31 | match.arg(transport, transports) |
| 32 | |
| 33 | if (transport == "ipc") |
| 34 | { |
| 35 | if (!missing(port)) |
| 36 | warning("Ignoring specified port for ipc transport.") |
| 37 | |
| 38 | paste0(transport, "://", host) |
| 39 | } |
| 40 | else |
| 41 | paste0(transport, "://", host, ":", port) |
| 42 | } |