| 1 |
\section[Examples]{Examples} |
| 2 |
\label{sec:examples} |
| 3 |
\addcontentsline{toc}{section}{\thesection. Examples} |
| 4 |
|
| 5 |
The package provides several simple examples based on \emph{the ZeroMQ guide |
| 6 |
for C developers} by Pieter Hintjens~\citep{Hintjens}. These are located in |
| 7 |
the \code{demo/} subdirectory of the \pkg{pbdZMQ} |
| 8 |
package source, and they include:\\ |
| 9 |
\begin{center} |
| 10 |
\vspace{0.2cm} |
| 11 |
\begin{tabular}{ll} \hline\hline |
| 12 |
Examples & Descriptions \\ \hline |
| 13 |
\code{hwclient.r} & hello world client \\ |
| 14 |
\code{hwserver.r} & hello world server \\ \hline |
| 15 |
|
| 16 |
\code{tasksink.r} & task sink from two workers \\ |
| 17 |
\code{taskvent.r} & task ventilator send jobs to two workers \\ |
| 18 |
\code{taskwork.r} & task workers \\ \hline |
| 19 |
|
| 20 |
\code{wuclient.r} & weather updating client \\ |
| 21 |
\code{wuserver.r} & weather updating server \\ \hline |
| 22 |
|
| 23 |
\code{mspoller.r} & using poller to receive messages from multiple sockets \\ |
| 24 |
\code{msreader.r} & receive messages from multiple sockets \\ \hline |
| 25 |
|
| 26 |
\code{mpclient.r} & hello world client in mpltiple part version \\ |
| 27 |
\code{mpserver.r} & hello world server in mpltiple part version \\ \hline |
| 28 |
\hline |
| 29 |
|
| 30 |
\end{tabular} |
| 31 |
\end{center} |
| 32 |
|
| 33 |
For instance, the task examples can be run by |
| 34 |
\begin{Command} |
| 35 |
Rscript taskwork.r & |
| 36 |
Rscript taskvent.r |
| 37 |
Rscript tasksink.r |
| 38 |
|
| 39 |
### Remember to kill two worker processors at the end, such as |
| 40 |
ps -x|grep "file=task.*\.r"|sed "s/\(.*\) pts.*/\1/"|xargs kill -9 |
| 41 |
\end{Command} |
| 42 |
Or, via \code{demo()} function as the hello world example in |
| 43 |
Section~\ref{sec:installation}. |
| 44 |
|
| 45 |
The weather updating examples can be run by |
| 46 |
\begin{Command} |
| 47 |
Rscript wuserver.r & |
| 48 |
Rscript wuclient.r |
| 49 |
rm weather.ipc |
| 50 |
\end{Command} |
| 51 |
Or, via \code{demo()} function as the hello world example in |
| 52 |
Section~\ref{sec:installation}. |
| 53 |
|