rpp.3 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. .\" Copyright (C) 1994-2018 Altair Engineering, Inc.
  2. .\" For more information, contact Altair at www.altair.com.
  3. .\"
  4. .\" This file is part of the PBS Professional ("PBS Pro") software.
  5. .\"
  6. .\" Open Source License Information:
  7. .\"
  8. .\" PBS Pro is free software. You can redistribute it and/or modify it under the
  9. .\" terms of the GNU Affero General Public License as published by the Free
  10. .\" Software Foundation, either version 3 of the License, or (at your option) any
  11. .\" later version.
  12. .\"
  13. .\" PBS Pro is distributed in the hope that it will be useful, but WITHOUT ANY
  14. .\" WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  15. .\" FOR A PARTICULAR PURPOSE.
  16. .\" See the GNU Affero General Public License for more details.
  17. .\"
  18. .\" You should have received a copy of the GNU Affero General Public License
  19. .\" along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. .\"
  21. .\" Commercial License Information:
  22. .\"
  23. .\" For a copy of the commercial license terms and conditions,
  24. .\" go to: (http://www.pbspro.com/UserArea/agreement.html)
  25. .\" or contact the Altair Legal Department.
  26. .\"
  27. .\" Altair’s dual-license business model allows companies, individuals, and
  28. .\" organizations to create proprietary derivative works of PBS Pro and
  29. .\" distribute them - whether embedded or bundled with other software -
  30. .\" under a commercial license agreement.
  31. .\"
  32. .\" Use of Altair’s trademarks, including but not limited to "PBS™",
  33. .\" "PBS Professional®", and "PBS Pro™" and Altair’s logos is subject to Altair's
  34. .\" trademark licensing policies.
  35. .\"
  36. .TH RPP 3 "1 Oct 2009" Local "PBS Professional"
  37. .SH NAME
  38. rpp_open, rpp_bind, rpp_poll, rpp_io, rpp_read, rpp_write, rpp_close, rpp_getaddr, rpp_flush, rpp_terminate, rpp_shutdown, rpp_rcommit, rpp_wcommit, rpp_eom, rpp_getc, rpp_putc \- reliable packet protocol
  39. .SH SYNOPSIS
  40. .B #include <sys/types.h>
  41. .br
  42. .B #include <netinet/in.h>
  43. .br
  44. .B #include <rpp.h>
  45. .LP
  46. .B
  47. int rpp_open(addr)
  48. .RS 6
  49. struct sockadd_in \(**addr;
  50. .RE
  51. .LP
  52. .B
  53. int rpp_bind(port)
  54. .RS 6
  55. int port;
  56. .RE
  57. .LP
  58. .B
  59. int rpp_poll()
  60. .LP
  61. .B
  62. int rpp_io()
  63. .LP
  64. .B
  65. int rpp_read(stream, buf, len)
  66. .RS 6
  67. u_int stream;
  68. .br
  69. char \(**buf;
  70. .br
  71. int len;
  72. .RE
  73. .LP
  74. .B
  75. int rpp_write(stream, buf, len)
  76. .RS 6
  77. u_int stream;
  78. .br
  79. char \(**buf;
  80. .br
  81. int len;
  82. .RE
  83. .LP
  84. .B
  85. int rpp_close(stream)
  86. .RS 6
  87. u_int stream;
  88. .RE
  89. .LP
  90. .B
  91. struct sockadd_in \(**rpp_getaddr(stream)
  92. .RS 6
  93. u_int stream;
  94. .RE
  95. .LP
  96. .B
  97. int rpp_flush(stream)
  98. .RS 6
  99. u_int stream;
  100. .RE
  101. .LP
  102. .B
  103. int rpp_terminate()
  104. .LP
  105. .B
  106. int rpp_shutdown()
  107. .LP
  108. .B
  109. int rpp_rcommit(stream, flag)
  110. .RS 6
  111. u_int stream;
  112. .br
  113. int flag;
  114. .RE
  115. .LP
  116. .B
  117. int rpp_wcommit(stream, flag)
  118. .RS 6
  119. u_int stream;
  120. .br
  121. int flag;
  122. .RE
  123. .LP
  124. .B
  125. int rpp_eom(stream)
  126. .RS 6
  127. u_int stream;
  128. .RE
  129. .LP
  130. .B
  131. int rpp_getc(stream)
  132. .RS 6
  133. u_int stream;
  134. .RE
  135. .LP
  136. .B
  137. int rpp_putc(stream, c)
  138. .RS 6
  139. u_int stream;
  140. .br
  141. int c;
  142. .RE
  143. .SH DESCRIPTION
  144. .LP
  145. These functions provide reliable, flow-controlled, two-way transmission
  146. of data. Each data path will be called a "stream" in this document.
  147. The advantage of RPP over TCP is that many streams can be multiplexed
  148. over one socket. This allows simultaneous connections over many
  149. streams without regard to the system imposed file descriptor limit.
  150. .LP
  151. Data is sent and received in "messages". A message may be of any
  152. length and is either received completely or not at all. Long
  153. messages will cause the library to use large amounts of memory
  154. in the heap by calling
  155. .BR malloc (3V).
  156. .LP
  157. In order to use any of the above with Windows, initialize the network
  158. library and link with
  159. .B winsock2.
  160. To do this, call
  161. .B winsock_init()
  162. before calling the function and link against the
  163. .B ws2_32.lib
  164. library.
  165. .B rpp_open(\|)
  166. initializes a new stream connection to
  167. .IR addr
  168. and returns the stream identifier. This is
  169. an integer with a value greater than or equal to zero. A negative
  170. number indicates an error. In this case, errno will be set.
  171. .LP
  172. .B rpp_bind(\|)
  173. is an initialization call which is used to bind the UDP socket used
  174. by RPP to a particular
  175. .IR port .
  176. The file descriptor of the UDP socket used by the library is returned.
  177. .LP
  178. .B rpp_poll(\|)
  179. returns the stream identifier of a stream with data to read. If
  180. no stream is ready to read,
  181. a -2 is returned. A -1 is returned if an error occurs.
  182. .LP
  183. .B rpp_io(\|)
  184. processes any packets which are waiting to be sent or received over
  185. the UDP socket. This routine should be called if a section of code
  186. could be executing for more than a few (~10) seconds without calling
  187. any other rpp function.
  188. A -1 is returned if an error occurs, 0 otherwise.
  189. .LP
  190. .B rpp_read(\!)
  191. transfers up to
  192. .IR len
  193. characters of a message from
  194. .IR stream
  195. into
  196. .IR buf .
  197. If all of a message has been read, the return value will be less than
  198. .IR len .
  199. The return value could be zero if all of a message had previously been
  200. read. A -1 is returned on error. A -2 is returned if the peer has
  201. closed its connection.
  202. If
  203. .B rpp_poll(\!)
  204. is used to determine the stream is ready for reading, the call to
  205. .IR rpp_read(\!)
  206. will return immediately. Otherwise, the call will block waiting for
  207. a message to arrive.
  208. .LP
  209. .B rpp_write(\|)
  210. adds information to the current message on a
  211. .IR stream .
  212. The data in
  213. .IR buf
  214. numbering
  215. .IR len
  216. characters is transferred to the stream.
  217. The number of characters added to the
  218. stream are returned or a -1 on error. In this case, errno will be set.
  219. A -2 is returned if the peer has closed its connection.
  220. .LP
  221. .B rpp_close(\!)
  222. disconnects the
  223. .IR stream
  224. from its peer and frees all resources associated with the stream.
  225. The return value is -1 on error and 0 otherwise.
  226. .LP
  227. .B rpp_getaddr(\!)
  228. returns the address which a
  229. .IR stream
  230. is connected to. If the stream is not open, a
  231. .SM NULL
  232. pointer is returned.
  233. .LP
  234. .B rpp_flush(\!)
  235. marks the end of a message and commits all the data which has been
  236. written to the specified
  237. .IR stream .
  238. A zero is returned if the message
  239. has been successfully committed.
  240. A -1 is returned on error.
  241. .LP
  242. .B rpp_terminate(\!)
  243. is used to free all memory associated with all streams and close the
  244. UDP socket. This is done without attempting to send any final messages
  245. that may be waiting. If a process is using
  246. .B rpp
  247. and calls
  248. .B fork() ,
  249. the child
  250. .B must
  251. call rpp_terminate() so it will not cause a conflict with the parent's
  252. communication.
  253. .LP
  254. .B rpp_shutdown(\!)
  255. is used to free all memory associated with all streams and close the
  256. UDP socket. An attempt is made to send all outstanding messages before
  257. returning.
  258. .LP
  259. .B rpp_rcommit(\!)
  260. is used to "commit" or "de-commit" the information read from a message.
  261. As calls are made to
  262. .IR rpp_read(\!) ,
  263. the number of characters transferred out of the message are counted. If
  264. .IR rpp_rcommit(\!)
  265. is called with
  266. .IR flag
  267. being non-zero (TRUE), the current position in the message is marked
  268. as the commit point. If
  269. .IR rpp_rcommit(\!)
  270. is called with
  271. .IR flag
  272. being zero (FALSE), a subsequent call to
  273. .IR rpp_read(\!)
  274. will return characters from the message following the last commit point.
  275. If an entire message has been read,
  276. .IR rpp_read(\!)
  277. will continue to return zero as the number of bytes transferred until
  278. .IR rpp_eom(\!)
  279. is called to commit the complete message.
  280. .LP
  281. .B rpp_wcommit(\!)
  282. is used to "commit" or "de-commit" the information written to a stream.
  283. As calls are made to
  284. .IR rpp_write(\!) ,
  285. the number of characters transferred into the message are counted. If
  286. .IR rpp_wcommit(\!)
  287. is called with
  288. .IR flag
  289. being non-zero (TRUE), the current position in the message is marked
  290. as the commit point. If
  291. .IR rpp_wcommit(\!)
  292. is called with
  293. .IR flag
  294. being zero (FALSE), a subsequent call to
  295. .IR rpp_write(\!)
  296. will transfer characters into the stream following the last commit point.
  297. A call to
  298. .IR rpp_flush(\!)
  299. does an automatic write commit to the current position.
  300. .LP
  301. .B rpp_eom(\!)
  302. is called to terminate processing of the current message.
  303. .SH SEE ALSO
  304. .BR tcp (4P),
  305. .BR udp (4P)