home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / mcast / part03 < prev    next >
Encoding:
Text File  |  1993-04-05  |  99.1 KB  |  3,258 lines

  1. Newsgroups: comp.sources.unix
  2. From: casey@gauss.llnl.gov (Casey Leedom)
  3. Subject: v26i107: mcast - LLNL IP multicast implementation, V1.2.3, Part03/04
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: casey@gauss.llnl.gov (Casey Leedom)
  8. Posting-Number: Volume 26, Issue 107
  9. Archive-Name: mcast/part03
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 3 (of 4)."
  18. # Contents:  ABSTRACT doc/cover.me include/netmcast/mcast.h
  19. #   libmcast/_mc_read.c man/mc_getsockopt.2 man/mc_read.2
  20. #   man/mc_recv.2 man/mc_send.2 man/mc_socket.2 man/mcast.4
  21. #   man/mcast_newaddr.3 man/mcast_sopen.3 man/mcastd.8 test/mc_ping.c
  22. # Wrapped by vixie@gw.home.vix.com on Tue Apr  6 12:49:50 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'ABSTRACT' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'ABSTRACT'\"
  26. else
  27. echo shar: Extracting \"'ABSTRACT'\" \(6014 characters\)
  28. sed "s/^X//" >'ABSTRACT' <<'END_OF_FILE'
  29. Identification:
  30. X
  31. X    Software Acronym: MCAST
  32. X    Software Title: Multicast Testbed Server and Library System
  33. X
  34. X
  35. Author Name(s) and Affiliations:
  36. X
  37. X    Leith Alan Leedom
  38. X    LLNL/Computation
  39. X
  40. X
  41. Software Completion Date:
  42. X
  43. X    May 15, 1992
  44. X
  45. X
  46. Brief Description:
  47. X
  48. X    This software is an experimental implementation of a multicast
  49. X    communication system.  It allows applications to communicate in a
  50. X    broadcast-like manner with other applications.  The system consists
  51. X    of a library interface modeled on the Berkeley socket abstraction, a
  52. X    communications server, and a complete set of manual pages.
  53. X
  54. X
  55. Method of Solution:
  56. X
  57. X    Multicast communication is simulated via the use of a communication
  58. X    server.  Applications connect to the server via a provided library.
  59. X
  60. X    The server maintains several message groups which are created and
  61. X    destroyed dynamically as applications connect to the server and
  62. X    subscribe to message groups.  Only one message group can be
  63. X    subscribed to on a connection at any one time.  Applications may
  64. X    subscribe to multiple message groups simultaneously by establishing
  65. X    multiple connections to the server.
  66. X
  67. X    When applications send messages to the server, the server resends
  68. X    those messages to all other applications subscribed to the same
  69. X    message group.
  70. X
  71. X
  72. Computer(s) for which software is written:
  73. X
  74. X    IBM platforms supporting AIX 3.2 or later.
  75. X    SGI platforms supporting IRIX 3.2 or later.
  76. X    Sun platforms supporting SunOS 4.1.1 or later.
  77. X
  78. X
  79. Operating System:
  80. X
  81. X    POSIX 1003.1-1990 with Berkeley socket, multiplexed I/O (select)
  82. X    and uio (writev) extensions.
  83. X
  84. X
  85. Programming Language(s) Used:
  86. X
  87. X    ANSI C X3.159-1989.
  88. X
  89. X
  90. Software limitations:
  91. X
  92. X    All data is dynamically allocated with the C malloc(unsigned int)
  93. X    library routine.  One fixed size array is used in the library to
  94. X    maintain information on each application connection to the server.
  95. X    This array is sized based on the Berkeley select constant FD_SETSIZE
  96. X    from the C include file <sys/types.h>.
  97. X
  98. X
  99. Unique Features of the Software:
  100. X
  101. X    The software is very simple and small.  It will allow researchers to
  102. X    experiment easily with multicast communication in applications.  It
  103. X    will allow researchers to experiment easily with different multicast
  104. X    communication paradigms and application program interfaces via simple
  105. X    code changes.
  106. X
  107. X
  108. Related and Auxiliary Software:
  109. X
  110. X    This is the first release of this software.  It does not supersede any
  111. X    other version.  It does not depend on any other software systems.
  112. X    The ISIS system from Cornell University provides a similar, but much
  113. X    more sophisticated and comprehensive capability.
  114. X
  115. X
  116. Other Programming or Operating Information or Restrictions:
  117. X
  118. X    Files in the top level directory whose names consist of all capital
  119. X    letters are general information files and should be read before all
  120. X    others.
  121. X
  122. X    Files ending in ".c" and ".h" are ANSI C source files.  Files ending
  123. X    in ".me" are troff documentation source files to be processed with
  124. X    the "me" troff macro package.  Files ending in ".N," where N is a
  125. X    single digit, are troff on-line manual pages to be processed with the
  126. X    "man" troff macro package.  Files whose names start with "Makefile"
  127. X    are part of the automatic software compilation and installation
  128. X    system for the software.
  129. X
  130. X
  131. Hardware Requirements:
  132. X
  133. X    No special hardware is required.
  134. X
  135. X
  136. Time requirements:
  137. X
  138. X    Message transmission is usually bounded by less than 10 milliseconds
  139. X    per 1024 bytes of message length on any reasonably performing system.
  140. X
  141. X
  142. References:
  143. X
  144. X    Reference documents that are provided with this package:
  145. X
  146. X    ./ (general info)    description
  147. X    -----------------    -----------
  148. X    ABSTRACT ..............    this file
  149. X    MEMO ..................    memo of understanding from software author
  150. X                to LLNL software release office
  151. X    README ................    overview of software and installation
  152. X                instructions
  153. X    TODO ..................    notes about remaining work to do on
  154. X                software
  155. X
  156. X    ./man/ (manual pages)    description
  157. X    ---------------------    -----------
  158. X    mc_bind.2 .............    bind a name to a multicast socket
  159. X    mc_close.2 ............    delete a multicast socket descriptor
  160. X    mc_connect.2 ..........    create an association between a multicast
  161. X                socket and a remote name
  162. X    mc_fcntl.2 ............    multicast socket control
  163. X    mc_getpeername.2 ......    get remote peer name of multicast socket
  164. X    mc_getsockname.2 ......    get (local) name of multicast socket
  165. X    mc_getsockopt.2 .......    get and set options on multicast sockets
  166. X    mc_ioctl.2 ............    control multicast socket
  167. X    mc_read.2 .............    read input from a multicast socket
  168. X    mc_recv.2 .............    receive a message from a multicast socket
  169. X    mc_send.2 .............    send a message to a multicast socket
  170. X    mc_shutdown.2 .........    shut down part of a full-duplex connection
  171. X    mc_socket.2 ...........    create a endpoint for multicast
  172. X                communication
  173. X    mc_write.2 ............    write output to a multicast socket
  174. X    mcast.4 ...............    multicast protocol
  175. X    mcast_getgroupbyname.3    get multicast address information
  176. X    mcast_newaddr.3 .......    create a new, globally unique multicast
  177. X                address
  178. X    mcast_sopen.3 .........    open a connection to a multicast group
  179. X    mcastd.8 ..............    multicast protocol server
  180. X
  181. X    ./doc/ (documentation)    description
  182. X    ----------------------    -----------
  183. X    cover.me ..............    cover page, contents, etc. for printer
  184. X                documentation
  185. X    notes.me ..............    general notes covering experiences with
  186. X                the software
  187. X
  188. X    Reference documents not provided with this package:
  189. X
  190. X    Sechrest, S., "An Introductory 4.3BSD Interprocess Communication
  191. X    Tutorial," 4.3BSD Document, UC Berkeley, 1986.
  192. X
  193. X    Leffler, S., Fabry, R., Joy, W., Lapsley, P., Miller, S.,
  194. X    Torek, C., "An Advanced 4.3BSD Interprocess Communication
  195. X    Tutorial," 4.3BSD Document, UC Berkeley, 1986.
  196. X
  197. X
  198. Categorization and Keywords:
  199. X
  200. X    Subject Classification Code: P
  201. X    Keywords: communications, computer networks, distributed data processing
  202. END_OF_FILE
  203. if test 6014 -ne `wc -c <'ABSTRACT'`; then
  204.     echo shar: \"'ABSTRACT'\" unpacked with wrong size!
  205. fi
  206. # end of 'ABSTRACT'
  207. fi
  208. if test -f 'doc/cover.me' -a "${1}" != "-c" ; then 
  209.   echo shar: Will not clobber existing file \"'doc/cover.me'\"
  210. else
  211. echo shar: Extracting \"'doc/cover.me'\" \(7604 characters\)
  212. sed "s/^X//" >'doc/cover.me' <<'END_OF_FILE'
  213. X.\" Copyright (c) 1992 The Regents of the University of California.
  214. X.\" All rights reserved.
  215. X.\"
  216. X.\" Redistribution and use in source and binary forms, with or without
  217. X.\" modification, are permitted provided that the following conditions
  218. X.\" are met:
  219. X.\" 1. Redistributions of source code must retain the above copyright
  220. X.\"    notice, this list of conditions and the following disclaimer.
  221. X.\" 2. Redistributions in binary form must reproduce the above copyright
  222. X.\"    notice, this list of conditions and the following disclaimer in the
  223. X.\"    documentation and/or other materials provided with the distribution.
  224. X.\" 3. All advertising materials mentioning features or use of this software
  225. X.\"    must display the following acknowledgement:
  226. X.\"    This product includes software developed by the University of
  227. X.\"    California, Lawrence Livermore National Laboratory and its
  228. X.\"    contributors.
  229. X.\" 4. Neither the name of the University nor the names of its contributors
  230. X.\"    may be used to endorse or promote products derived from this software
  231. X.\"    without specific prior written permission.
  232. X.\"
  233. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  234. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  235. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  236. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  237. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  238. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  239. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  240. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  241. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  242. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  243. X.\" SUCH DAMAGE.
  244. X.\"
  245. X.po 1.0in
  246. X.ll 6.5in
  247. X.nr pi 0n
  248. X.de Hd
  249. X.ds Vr \\$3
  250. X.ds Dt \\$4
  251. X..
  252. X.Hd $Header: /u0/casey/src/mcast/doc/RCS/cover.me,v 1.2 93/01/21 09:56:28 casey Exp $
  253. X.of 'LLNL MCAST version \*(Vr''\*(Dt'
  254. X.ef '\*(Dt''LLNL MCAST version \*(Vr'
  255. X.(b C
  256. X.sz +10
  257. X.rs
  258. X.sp 2.25in
  259. LLNL MCAST
  260. X.sp .5in
  261. Distribution
  262. X.sp 2in
  263. Version \*(Vr
  264. X\*(Dt
  265. X.sz -10
  266. X.)b
  267. X.\" We delay defining the footer so it won't show up on the first page ...
  268. X.of 'LLNL MCAST version \*(Vr''\*(Dt'
  269. X.ef '\*(Dt''LLNL MCAST version \*(Vr'
  270. X.pa
  271. X.rs
  272. X.sp 3.75in
  273. Copyright (c) 1992 The Regents of the University of California.
  274. All rights reserved.
  275. X.pp
  276. Redistribution and use in source and binary forms, with or without
  277. modification, are permitted provided that the following conditions
  278. are met:
  279. X.ip 1.
  280. Redistributions of source code must retain the above copyright
  281. notice, this list of conditions and the following disclaimer.
  282. X.ip 2.
  283. Redistributions in binary form must reproduce the above copyright
  284. notice, this list of conditions and the following disclaimer in the
  285. documentation and/or other materials provided with the distribution.
  286. X.ip 3.
  287. All advertising materials mentioning features or use of this software
  288. must display the following acknowledgement:
  289. X.(q
  290. This product includes software developed by the University of
  291. California, Berkeley and its contributors.
  292. X.)q
  293. X.ip 4.
  294. Neither the name of the University nor the names of its contributors
  295. may be used to endorse or promote products derived from this software
  296. without specific prior written permission.
  297. X.pp
  298. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  299. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  300. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  301. ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  302. XFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  303. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  304. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  305. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  306. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  307. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  308. SUCH DAMAGE.
  309. X.pa
  310. X.(b C
  311. X.sz +2
  312. Contents
  313. X.sz -2
  314. X.)b
  315. X.sp 3v
  316. X.(x c
  317. Introduction
  318. X.)x 1
  319. X.(x c
  320. README
  321. X.)x 2
  322. X.(x c
  323. ABSTRACT
  324. X.)x 3
  325. X.(x c
  326. MEMO
  327. X.)x 4
  328. X.(x c
  329. TODO
  330. X.)x 5
  331. X.(x c
  332. Implementation notes
  333. X.)x 6
  334. X.(x c
  335. Manual pages
  336. X.)x 7
  337. X.(x c
  338. Include file sources
  339. X.)x 8
  340. X.(x c
  341. Multicast server source
  342. X.)x 9
  343. X.(x c
  344. Multicast application programming interface sources
  345. X.)x 10
  346. X.(x c
  347. Multicast example application sources
  348. X.)x 11
  349. X.xp c
  350. X.pa
  351. X.(b C
  352. X.sz +2
  353. X1
  354. X.sp 1v
  355. Introduction
  356. X.sz -2
  357. X.)b
  358. X.sp 3v
  359. X.pp
  360. This document contains the documentation and source code to the LLNL MCAST
  361. software distribution version \*(Vr.
  362. X.pp
  363. The LLNL MCAST software is an experimental implementation of a
  364. multicast communication system.  It allows applications to communicate
  365. in a broadcast-like manner with other applications.  Multicast would
  366. typically be used by the parts of a distributed application.
  367. X.pp
  368. The system consists of an application programming interface (API)
  369. modeled on the Berkeley socket abstraction, a communications server,
  370. and a complete set of manual pages.
  371. X.pp
  372. The communication server implements the multicast message passing
  373. semantics.  A version of the system which uses network level multicast
  374. facilities is planned, but we needed something up and running quickly
  375. so other members of our project team could proceed with their work.
  376. Hence, this version.  Our goal is to be able to slip in a true
  377. multicast implementation using the same API under our applications
  378. without the applications noticing the difference ...
  379. X.pa
  380. X.(b C
  381. X.sz +2
  382. X2
  383. X.sp 1v
  384. README
  385. X.sz -2
  386. X.)b
  387. X.pa
  388. X.(b C
  389. X.sz +2
  390. X3
  391. X.sp 1v
  392. ABSTRACT
  393. X.sz -2
  394. X.)b
  395. X.pa
  396. X.(b C
  397. X.sz +2
  398. X4
  399. X.sp 1v
  400. MEMO
  401. X.sz -2
  402. X.)b
  403. X.pa
  404. X.(b C
  405. X.sz +2
  406. X5
  407. X.sp 1v
  408. TODO
  409. X.sz -2
  410. X.)b
  411. X.pa
  412. X.(b C
  413. X.sz +2
  414. X6
  415. X.sp 1v
  416. Implementation notes
  417. X.sz -2
  418. X.)b
  419. X.pa
  420. X.(b C
  421. X.sz +2
  422. X7
  423. X.sp 1v
  424. Manual pages
  425. X.sz -2
  426. X.)b
  427. X.sp 3v
  428. X.pp
  429. X.(x m
  430. mc_bind.2
  431. X.)x 1
  432. X.(x m
  433. mc_close.2
  434. X.)x 2
  435. X.(x m
  436. mc_connect.2
  437. X.)x 3
  438. X.(x m
  439. mc_fcntl.2
  440. X.)x 4
  441. X.(x m
  442. mc_getpeername.2
  443. X.)x 5
  444. X.(x m
  445. mc_getsockname.2
  446. X.)x 6
  447. X.(x m
  448. mc_getsockopt.2
  449. X.)x 7
  450. X.(x m
  451. mc_ioctl.2
  452. X.)x 8
  453. X.(x m
  454. mc_read.2
  455. X.)x 9
  456. X.(x m
  457. mc_recv.2
  458. X.)x 10
  459. X.(x m
  460. mc_send.2
  461. X.)x 11
  462. X.(x m
  463. mc_shutdown.2
  464. X.)x 12
  465. X.(x m
  466. mc_socket.2
  467. X.)x 13
  468. X.(x m
  469. mc_write.2
  470. X.)x 14
  471. X.(x m
  472. mcast.4
  473. X.)x 15
  474. X.(x m
  475. mcast_getgroupbyname.3
  476. X.)x 16
  477. X.(x m
  478. mcast_newaddr.3
  479. X.)x 17
  480. X.(x m
  481. mcast_sopen.3
  482. X.)x 18
  483. X.(x m
  484. mcastd.8
  485. X.)x 19
  486. X.xp m
  487. X.pa
  488. X.(b C
  489. X.sz +2
  490. X8
  491. X.sp 1v
  492. Include file sources
  493. X.sz -2
  494. X.)b
  495. X.sp 3v
  496. X.pp
  497. X.(x i
  498. include/netmcast/mcast.h
  499. X.)x 1
  500. X.(x i
  501. include/netmcast/mcastd.h
  502. X.)x 2
  503. X.xp i
  504. X.pa
  505. X.(b C
  506. X.sz +2
  507. X9
  508. X.sp 1v
  509. Multicast server source
  510. X.sz -2
  511. X.)b
  512. X.sp 3v
  513. X.(x d
  514. mcastd/mcastd.c
  515. X.)x 1
  516. X.xp d
  517. X.pa
  518. X.(b C
  519. X.sz +2
  520. X10
  521. X.sp 1v
  522. Multicast application programming interface sources
  523. X.sz -2
  524. X.)b
  525. X.sp 3v
  526. X.pp
  527. X.(x a
  528. mc_lib.h
  529. X.)x 1
  530. X.(x a
  531. X_mc_read.c
  532. X.)x 2
  533. X.(x a
  534. X_mc_state.c
  535. X.)x 3
  536. X.(x a
  537. X_mc_write.c
  538. X.)x 4
  539. X.(x a
  540. mc_bind.c
  541. X.)x 5
  542. X.(x a
  543. mc_close.c
  544. X.)x 6
  545. X.(x a
  546. mc_connect.c
  547. X.)x 7
  548. X.(x a
  549. mc_fcntl.c
  550. X.)x 8
  551. X.(x a
  552. mc_getpeername.c
  553. X.)x 9
  554. X.(x a
  555. mc_getsockname.c
  556. X.)x 10
  557. X.(x a
  558. mc_getsockopt.c
  559. X.)x 11
  560. X.(x a
  561. mc_ioctl.c
  562. X.)x 12
  563. X.(x a
  564. mc_read.c
  565. X.)x 13
  566. X.(x a
  567. mc_readv.c
  568. X.)x 14
  569. X.(x a
  570. mc_recv.c
  571. X.)x 15
  572. X.(x a
  573. mc_recvfrom.c
  574. X.)x 16
  575. X.(x a
  576. mc_send.c
  577. X.)x 17
  578. X.(x a
  579. mc_sendto.c
  580. X.)x 18
  581. X.(x a
  582. mc_setsockopt.c
  583. X.)x 19
  584. X.(x a
  585. mc_shutdown.c
  586. X.)x 20
  587. X.(x a
  588. mc_socket.c
  589. X.)x 21
  590. X.(x a
  591. mc_write.c
  592. X.)x 22
  593. X.(x a
  594. mc_writev.c
  595. X.)x 23
  596. X.(x a
  597. mcast_getgroupbyname.c
  598. X.)x 24
  599. X.(x a
  600. mcast_newaddr.c
  601. X.)x 25
  602. X.(x a
  603. mcast_sopen.c
  604. X.)x 26
  605. X.xp a
  606. X.pa
  607. X.(b C
  608. X.sz +2
  609. X11
  610. X.sp 1v
  611. Multicast example application sources
  612. X.sz -2
  613. X.)b
  614. X.sp 3v
  615. X.pp
  616. X.(x t
  617. mc_clock.c
  618. X.)x 1
  619. X.(x t
  620. mc_hello.c
  621. X.)x 2
  622. X.(x t
  623. mc_listen.c
  624. X.)x 3
  625. X.(x t
  626. mc_ping.c
  627. X.)x 4
  628. X.(x t
  629. mc_send.c
  630. X.)x 5
  631. X.xp t
  632. END_OF_FILE
  633. if test 7604 -ne `wc -c <'doc/cover.me'`; then
  634.     echo shar: \"'doc/cover.me'\" unpacked with wrong size!
  635. fi
  636. # end of 'doc/cover.me'
  637. fi
  638. if test -f 'include/netmcast/mcast.h' -a "${1}" != "-c" ; then 
  639.   echo shar: Will not clobber existing file \"'include/netmcast/mcast.h'\"
  640. else
  641. echo shar: Extracting \"'include/netmcast/mcast.h'\" \(7755 characters\)
  642. sed "s/^X//" >'include/netmcast/mcast.h' <<'END_OF_FILE'
  643. X/*
  644. X * $Header: /u0/casey/src/mcast/include/netmcast/RCS/mcast.h,v 1.5 93/03/17 11:35:50 casey Exp $
  645. X */
  646. X
  647. X/*
  648. X * Copyright (c) 1992 The Regents of the University of California.
  649. X * All rights reserved.
  650. X *
  651. X * Redistribution and use in source and binary forms, with or without
  652. X * modification, are permitted provided that the following conditions
  653. X * are met:
  654. X * 1. Redistributions of source code must retain the above copyright
  655. X *    notice, this list of conditions and the following disclaimer.
  656. X * 2. Redistributions in binary form must reproduce the above copyright
  657. X *    notice, this list of conditions and the following disclaimer in the
  658. X *    documentation and/or other materials provided with the distribution.
  659. X * 3. All advertising materials mentioning features or use of this software
  660. X *    must display the following acknowledgement:
  661. X *    This product includes software developed by the University of
  662. X *    California, Lawrence Livermore National Laboratory and its
  663. X *    contributors.
  664. X * 4. Neither the name of the University nor the names of its contributors
  665. X *    may be used to endorse or promote products derived from this software
  666. X *    without specific prior written permission.
  667. X *
  668. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  669. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  670. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  671. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  672. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  673. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  674. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  675. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  676. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  677. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  678. X * SUCH DAMAGE.
  679. X */
  680. X
  681. X#ifndef _MCAST_H_
  682. X#define    _MCAST_H_
  683. X
  684. X/*
  685. X * Multicast address format; used for both group and member addresses.
  686. X * There's a lot missing here.  Multicast group addresses may really need
  687. X * to be variable length and hierachical in order to be able to create
  688. X * unique addresses in a totally distributed manner.  Who knows ...  There's
  689. X * also the question of whether we should have separate address formats for
  690. X * group and member addresses.  Since they both have the same design needs,
  691. X * we've gone with a single address for now ...
  692. X *
  693. X * NOTE: The routine "mcast_newaddr" knows about the size and format of this
  694. X * type.  If you change the type, mc_newaddr must also be changed
  695. X * correspondingly.
  696. X */
  697. typedef struct mc_addr { /* MACHINE DEPENDENT */
  698. X    unsigned int    host:32;    /* host ID (probably too small) */
  699. X    unsigned int    process:32;    /* process ID */
  700. X    unsigned int    time:32;    /* time (definitely too small) */
  701. X    unsigned int    sequence:32;    /* sequence number (probably too small) */
  702. X} mc_addr;
  703. X
  704. static const struct mc_addr MCADDR_ANY = {
  705. X    0x00000000, 0x00000000, 0x00000000, 0x00000000
  706. X};
  707. static const struct mc_addr MCADDR_BROADCAST    = {
  708. X    0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
  709. X};
  710. X/*
  711. X * Note that, because of limitations in ANSI C's ability to use const
  712. X * variables, ANSI C applications won't be able to use MCADDR_ANY and
  713. X * MCADDR_BROADCAST to initialize static scope variables ...  Unfortunately
  714. X * there is no other way to construct a constant instance of a structure
  715. X * in C (or C++, but it's not quite so noticible there because C++ doesn't
  716. X * suffer ANSI C's limitations with regard to static scope variable
  717. X * initialization).
  718. X */
  719. X
  720. X#define    MCADDR_EQ(a, b) \
  721. X    (memcmp(&a, &b, sizeof(mc_addr)) == 0)
  722. X
  723. X
  724. X/*
  725. X * Multicast network layer message header format.  So far this is really
  726. X * simple since the only transport implementation is via a server and much
  727. X * of the ``protocol'' is handled implicitly by the server.  Questions abound
  728. X * as to whether this should be layered on top of some other protcol like
  729. X * IP and what will be required to support a real distributed implementation,
  730. X * security to prevent random messages from disrupting communications, etc..
  731. X * Note that it's impossible to send a multicast message without joining the
  732. X * multicast group it's destined for.  Birman thinks this is wrong.
  733. X */
  734. typedef struct mc_header { /* MACHINE DEPENDENT */
  735. X    unsigned int    version:8;    /* protocol version */
  736. X    unsigned int    hlength:8;    /* header length */
  737. X    unsigned int    :16;        /* pad to 32 bits */
  738. X    unsigned int    length:32;    /* length of header + data */
  739. X    mc_addr        group;        /* multicast group */
  740. X    mc_addr        source;        /* source of this message */
  741. X    mc_addr        destination;    /* destination of this message */
  742. X    /* message data follows this minimum header */
  743. X} mc_header;
  744. X
  745. X#define    MCVERSION    1        /* mcast protocol version number */
  746. X#define    MCHEADER_CORE \
  747. X    offsetof(mc_header, group)    /* includes version and lengths */
  748. X#define    MCHEADER_MIN \
  749. X    sizeof(mc_header)        /* minimum legal header length */
  750. X#define    MCHEADER_MAX \
  751. X    sizeof(mc_header)        /* maximum legal header length */
  752. X
  753. X/* multicast and atomic multicast protocols */
  754. X#define    AF_MCAST    80        /* must be unique ... */
  755. X#define    PF_MCAST    AF_MCAST    /* must be the same as AF_MCAST */
  756. X#define    AF_AMCAST    81        /* must be unique ... */
  757. X#define    PF_AMCAST    AF_AMCAST    /* must be the same as AF_AMCAST */
  758. X
  759. X
  760. X/*
  761. X * ``system calls'' (sic)
  762. X */
  763. X
  764. typedef struct sockaddr_mcast {
  765. X    short        family;        /* AF_MCAST or AF_AMCAST */
  766. X    mc_addr        group;        /* multicast group ID */
  767. X    mc_addr        member;        /* multicast group member ID */
  768. X} sockaddr_mcast;
  769. X
  770. X#ifdef __cplusplus
  771. extern "C" {
  772. X#endif
  773. int mc_bind(int s, const struct sockaddr *name, int namelen);
  774. int mc_close(int s);
  775. int mc_connect(int s, const struct sockaddr *name, int namelen);
  776. int mc_fcntl(int s, int request, ...);
  777. int mc_getpeername(int s, struct sockaddr *name, int *namelen);
  778. int mc_getsockname(int s, struct sockaddr *name, int *namelen);
  779. int mc_getsockopt(int s, int level, int optname, void *optval, int *optlen);
  780. int mc_ioctl(int s, int request, ...);
  781. int mc_read(int s, void *buf, size_t len);
  782. int mc_readv(int s, const struct iovec *iov, int iovcnt);
  783. int mc_recv(int s, void *buf, int len, int flags);
  784. int mc_recvfrom(int s, void *buf, int len, int flags,
  785. X        struct sockaddr *from, int *fromlen);
  786. int mc_send(int s, const void *buf, int len, int flags);
  787. int mc_sendto(int s, const void *buf, int len, int flags,
  788. X          struct sockaddr *to, int tolen);
  789. int mc_setsockopt(int s, int level, int optname,
  790. X          const void *optval, int optlen);
  791. int mc_shutdown(int s, int how);
  792. int mc_socket(int domain, int type, int protocol);
  793. int mc_write(int s, const void *buf, size_t len);
  794. int mc_writev(int s, const struct iovec *iov, int iovcnt);
  795. X#ifdef __cplusplus
  796. X}
  797. X#endif
  798. X
  799. X/* ioctl(2) defines.  "_IO*" macros are defined in <sys/ioctl.h> */
  800. X#define    MCIOCLOOPBACK    _IOW('m', 127, int)
  801. X                    /* set/clear loopback delivery */
  802. X
  803. X/* open(2) and fcntl(2) flag defines */
  804. X#define    O_DEV1        0x0100        /* device specific flag 1 */
  805. X#define    O_DEV2        0x0200        /* device specific flag 2 */
  806. X#define    O_DEV3        0x0400        /* device specific flag 3 */
  807. X#define    O_DEV4        0x0800        /* device specific flag 4 */
  808. X#define    O_DEV        (O_DEV1|O_DEV2|O_DEV3|O_DEV4)
  809. X
  810. X#define    MCO_LOOPBACK    O_DEV1        /* loopback sender messages */
  811. X
  812. X/*
  813. X * standard library
  814. X */
  815. X
  816. typedef struct mcastent { /* really need a generic name/value system! */
  817. X    char        *name;        /* official name of group */
  818. X    char        **aliases;    /* alias list */
  819. X    int        family;        /* address family */
  820. X    mc_addr        address;    /* address bound to group */
  821. X} mcastent;
  822. X
  823. X#ifdef __cplusplus
  824. extern "C" {
  825. X#endif
  826. struct mcastent *mcast_getgroupbyname(const char *name, int domain);
  827. int mcast_newaddr(struct mc_addr *addr);
  828. int mcast_sopen(const char *group, int domain, int type, int mode);
  829. X#ifdef __cplusplus
  830. X}
  831. X#endif
  832. X
  833. X#endif /* _MCAST_H_ */
  834. END_OF_FILE
  835. if test 7755 -ne `wc -c <'include/netmcast/mcast.h'`; then
  836.     echo shar: \"'include/netmcast/mcast.h'\" unpacked with wrong size!
  837. fi
  838. # end of 'include/netmcast/mcast.h'
  839. fi
  840. if test -f 'libmcast/_mc_read.c' -a "${1}" != "-c" ; then 
  841.   echo shar: Will not clobber existing file \"'libmcast/_mc_read.c'\"
  842. else
  843. echo shar: Extracting \"'libmcast/_mc_read.c'\" \(6360 characters\)
  844. sed "s/^X//" >'libmcast/_mc_read.c' <<'END_OF_FILE'
  845. X/*
  846. X * $Header: /u0/casey/src/mcast/libmcast/RCS/_mc_read.c,v 1.4 93/04/06 11:31:06 casey Exp $
  847. X */
  848. X
  849. X/*
  850. X * Copyright (c) 1992 The Regents of the University of California.
  851. X * All rights reserved.
  852. X *
  853. X * Redistribution and use in source and binary forms, with or without
  854. X * modification, are permitted provided that the following conditions
  855. X * are met:
  856. X * 1. Redistributions of source code must retain the above copyright
  857. X *    notice, this list of conditions and the following disclaimer.
  858. X * 2. Redistributions in binary form must reproduce the above copyright
  859. X *    notice, this list of conditions and the following disclaimer in the
  860. X *    documentation and/or other materials provided with the distribution.
  861. X * 3. All advertising materials mentioning features or use of this software
  862. X *    must display the following acknowledgement:
  863. X *    This product includes software developed by the University of
  864. X *    California, Lawrence Livermore National Laboratory and its
  865. X *    contributors.
  866. X * 4. Neither the name of the University nor the names of its contributors
  867. X *    may be used to endorse or promote products derived from this software
  868. X *    without specific prior written permission.
  869. X *
  870. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  871. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  872. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  873. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  874. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  875. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  876. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  877. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  878. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  879. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  880. X * SUCH DAMAGE.
  881. X */
  882. X
  883. X#ifndef lint
  884. static char rcsid[] = "$Header: /u0/casey/src/mcast/libmcast/RCS/_mc_read.c,v 1.4 93/04/06 11:31:06 casey Exp $";
  885. static char copyright[] =
  886. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  887. X    "All rights reserved.\n";
  888. static char classification[] =
  889. X    "Unclassified\n";
  890. X#endif
  891. X
  892. X
  893. X/*
  894. X * MCAST SYSLIB PRIVATE: _mc_read and _mc_pullup helper routines.
  895. X */
  896. X
  897. X
  898. X#include "mc_lib.h"
  899. X
  900. X
  901. static int _read(int fd, void *buf, int len);
  902. X
  903. X
  904. int
  905. X_mc_read(int s, void *buf, size_t len, int flags, mc_addr *from)
  906. X    /*
  907. X     * Read len bytes into buf from multicast group attached to socket s.
  908. X     * If from is non-NULL, assign source member address to *from.  Flags
  909. X     * may be used to specify MSG_PEEK.
  910. X     */
  911. X{
  912. X    mc_state *sp = &_mc_state[s];
  913. X    int nread, cc;
  914. X
  915. X    if (flags & ~(MSG_PEEK|MSG_OOB)) {
  916. X        errno = EINVAL;
  917. X        return(-1);
  918. X    }
  919. X    if (flags & ~(MSG_PEEK)) {
  920. X        /* we only support MSG_PEEK so far ... */
  921. X        errno = ENOPROTOOPT;
  922. X        return(-1);
  923. X    }
  924. X    if (sp->resid == 0)
  925. X        if (_mc_pullup(s, sp->flags) < 0)
  926. X            return(-1);
  927. X    cc = min(len, sp->resid);
  928. X    if (flags & MSG_PEEK)
  929. X        cc = recv(s, buf, cc, MSG_PEEK);
  930. X    else
  931. X        cc = _read(s, buf, cc);
  932. X    if (cc < 0)
  933. X        return(-1);
  934. X    if (!(flags & MSG_PEEK)) {
  935. X        sp->resid -= cc;
  936. X        if (sp->resid > 0 && sp->type != SOCK_STREAM) {
  937. X            /* datagram type: throw away unread message bytes */
  938. X            nread = _read(s, NULL, sp->resid);
  939. X            if (nread < 0)
  940. X                return(-1);
  941. X            sp->resid = 0;
  942. X        }
  943. X    }
  944. X    if (from != NULL)
  945. X        *from = sp->source;
  946. X    return(cc);
  947. X}
  948. X
  949. X
  950. int
  951. X_mc_pullup(int s, int flags)
  952. X    /*
  953. X     * Pull up next message from server if there is no remaining data from
  954. X     * last message.  Flags specifies whether pullup should block or not
  955. X     * (O_NONBLOCK).  Returns amount of data available for reading.
  956. X     */
  957. X{
  958. X    mc_state *sp = &_mc_state[s];
  959. X    mc_header header;
  960. X    int nread;
  961. X    unsigned int ver, hlen, len;
  962. X
  963. X    again:
  964. X    if (sp->resid != 0)
  965. X        return(sp->resid);
  966. X    if (flags & O_NONBLOCK) {
  967. X        long n;
  968. X        extern int ioctl(int, int, ...);
  969. X    
  970. X        if (ioctl(s, FIONREAD, &n) < 0)
  971. X            return(-1);
  972. X        if (n == 0) {
  973. X            errno = EAGAIN;
  974. X            return(-1);
  975. X        }
  976. X    }
  977. X    nread = _read(s, &header, sizeof(header));
  978. X    if (nread < 0)
  979. X        return(-1);
  980. X    ver = header.version;
  981. X    hlen = header.hlength;
  982. X    len = ntohl(header.length);
  983. X    if (ver != MCVERSION
  984. X        || hlen < MCHEADER_MIN || hlen > MCHEADER_MAX
  985. X        || len < hlen) {
  986. X        (void)fprintf(stderr, "_mc_read: packet format error:"
  987. X                  " ver = %d, hlen = %d, len = %d\n",
  988. X                  (int)ver, (int)hlen, (int)len);
  989. X        sp->state |= MC_CORRUPTED;
  990. X        errno = EIO;
  991. X        return(-1);
  992. X    }
  993. X    if (!MCADDR_EQ(header.group, sp->group)
  994. X        || (!MCADDR_EQ(header.destination, MCADDR_BROADCAST)
  995. X        && !MCADDR_EQ(header.destination, sp->local))
  996. X        || ((sp->state & MC_CONNECTED)
  997. X        && !MCADDR_EQ(header.destination, sp->remote))) {
  998. X
  999. X        /* misaddressed message; probably was just buffered up ... */
  1000. X        nread = _read(s, NULL, len-sizeof(header));
  1001. X        if (nread < 0)
  1002. X            return(-1);
  1003. X        else
  1004. X            goto again;
  1005. X    }
  1006. X    if (hlen > sizeof(header)) {
  1007. X        nread = _read(s, NULL, hlen-sizeof(header));
  1008. X        if (nread < 0)
  1009. X            return(nread);
  1010. X    }
  1011. X    sp->source = header.source;
  1012. X    sp->resid = len-hlen;
  1013. X    return(sp->resid);
  1014. X}
  1015. X
  1016. X
  1017. static int
  1018. X_read(int fd, void *buf, int len)
  1019. X    /*
  1020. X     * Read len bytes into buf from fd.  If buf is NULL, just read and
  1021. X     * throw away len bytes from fd ...
  1022. X     *
  1023. X     * While this may strike you as silly, it turns out that reads of large
  1024. X     * messages on STREAM sockets may return without having read all that
  1025. X     * you asked for.  Something in the underlaying transport is breaking
  1026. X     * the large messages up. (sigh) Read(2) should not prematurely return
  1027. X     * unless the file descriptor was set for non-blocking I/O!
  1028. X     *
  1029. X     * Another consideration is the possibility of the read call being
  1030. X     * interrupted by some underlaying asynchronous event system.  Thus, we
  1031. X     * need to check if a call returned with an EINTR and continue if so ...
  1032. X     */
  1033. X{
  1034. X    char *bp, trash[1024];
  1035. X    int nread, resid;
  1036. X
  1037. X    bp = buf;
  1038. X    resid = len;
  1039. X    while (resid > 0) {
  1040. X        if (buf == NULL)
  1041. X            nread = read(fd, trash, min(sizeof(trash), resid));
  1042. X        else
  1043. X            nread = read(fd, bp, resid);
  1044. X        if (nread < 0) {
  1045. X            if (errno == EINTR)
  1046. X                continue;
  1047. X            else
  1048. X                break;
  1049. X        }
  1050. X        if (nread == 0)
  1051. X            break;
  1052. X        bp += nread;
  1053. X        resid -= nread;
  1054. X    }
  1055. X    if (resid > 0) {
  1056. X        /* hopelessly out of sync with server */
  1057. X        _mc_state[fd].state |= MC_CORRUPTED;
  1058. X        errno = EIO;
  1059. X        return(-1);
  1060. X    }
  1061. X    return(len - resid);
  1062. X}
  1063. END_OF_FILE
  1064. if test 6360 -ne `wc -c <'libmcast/_mc_read.c'`; then
  1065.     echo shar: \"'libmcast/_mc_read.c'\" unpacked with wrong size!
  1066. fi
  1067. # end of 'libmcast/_mc_read.c'
  1068. fi
  1069. if test -f 'man/mc_getsockopt.2' -a "${1}" != "-c" ; then 
  1070.   echo shar: Will not clobber existing file \"'man/mc_getsockopt.2'\"
  1071. else
  1072. echo shar: Extracting \"'man/mc_getsockopt.2'\" \(6401 characters\)
  1073. sed "s/^X//" >'man/mc_getsockopt.2' <<'END_OF_FILE'
  1074. X.\" Copyright (c) 1992 The Regents of the University of California.
  1075. X.\" All rights reserved.
  1076. X.\"
  1077. X.\" Redistribution and use in source and binary forms, with or without
  1078. X.\" modification, are permitted provided that the following conditions
  1079. X.\" are met:
  1080. X.\" 1. Redistributions of source code must retain the above copyright
  1081. X.\"    notice, this list of conditions and the following disclaimer.
  1082. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1083. X.\"    notice, this list of conditions and the following disclaimer in the
  1084. X.\"    documentation and/or other materials provided with the distribution.
  1085. X.\" 3. All advertising materials mentioning features or use of this software
  1086. X.\"    must display the following acknowledgement:
  1087. X.\"    This product includes software developed by the University of
  1088. X.\"    California, Lawrence Livermore National Laboratory and its
  1089. X.\"    contributors.
  1090. X.\" 4. Neither the name of the University nor the names of its contributors
  1091. X.\"    may be used to endorse or promote products derived from this software
  1092. X.\"    without specific prior written permission.
  1093. X.\"
  1094. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1095. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1096. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1097. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1098. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1099. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1100. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1101. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1102. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1103. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1104. X.\" SUCH DAMAGE.
  1105. X.\"
  1106. X.de Hd
  1107. X.ds Dt \\$4
  1108. X..
  1109. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_getsockopt.2,v 1.1 92/10/16 18:23:02 casey Exp $
  1110. X.TH MC_GETSOCKOPT 2 \*(Dt
  1111. X.SH NAME
  1112. mc_getsockopt, mc_setsockopt \- get and set options on multicast sockets
  1113. X.SH SYNOPSIS
  1114. X.nf
  1115. X.ft B
  1116. X#include <sys/types.h>
  1117. X#include <sys/socket.h>
  1118. X#include <netmcast/mcast.h>
  1119. X
  1120. int
  1121. mc_getsockopt(int s, int level, int optname,
  1122. X              void *optval, int *optlen)
  1123. X
  1124. int
  1125. mc_setsockopt(int s, int level, int optname,
  1126. X              const void *optval, int optlen)
  1127. X.ft P
  1128. X.fi
  1129. X.SH DESCRIPTION
  1130. X.I Mc_getsockopt
  1131. and
  1132. X.I mc_setsockopt
  1133. manipulate the
  1134. X.I options
  1135. associated with a socket.  Options may exist at multiple
  1136. protocol levels; they are always present at the uppermost
  1137. X.I socket
  1138. level.
  1139. X.PP
  1140. When manipulating socket options the level at which the
  1141. option resides and the name of the option must be specified.
  1142. To manipulate options at the socket level,
  1143. X.I level
  1144. is specified as
  1145. SOL_SOCKET.
  1146. Currently multicast sockets don't support any other level.
  1147. X.PP
  1148. The parameters
  1149. X.I optval
  1150. and
  1151. X.I optlen
  1152. are used to access option values for
  1153. X.I setsockopt .
  1154. XFor
  1155. X.I getsockopt
  1156. they identify a buffer in which the value for the
  1157. requested option(s) are to be returned.  For
  1158. X.IR getsockopt ,
  1159. X.I optlen
  1160. is a value-result parameter, initially containing the
  1161. size of the buffer pointed to by
  1162. X.IR optval ,
  1163. and modified on return to indicate the actual size of
  1164. the value returned.  If no option value is
  1165. to be supplied or returned,
  1166. X.I optval
  1167. may be NULL.
  1168. X.PP
  1169. X.I Optname
  1170. and any specified options are passed uninterpreted to the appropriate
  1171. protocol module for interpretation.
  1172. The include file
  1173. X.I
  1174. X.I <sys/socket.h>
  1175. contains definitions for
  1176. socket level options, described below.
  1177. Options at other protocol levels vary in format and
  1178. name; consult the appropriate entries in
  1179. section
  1180. X4 of the manual.
  1181. X.PP
  1182. Most socket-level options utilize an
  1183. X.I int
  1184. parameter for
  1185. X.IR optval .
  1186. XFor
  1187. X.IR setsockopt ,
  1188. the parameter should be non-zero to enable a boolean option,
  1189. or zero if the option is to be disabled.
  1190. X.PP
  1191. The following options are recognized at the socket level for
  1192. multicast sockets.
  1193. XExcept as noted, each may be examined with
  1194. X.I getsockopt
  1195. and set with
  1196. X.I setsockopt .
  1197. X.PP
  1198. X.RS
  1199. X.nf
  1200. SO_SNDBUF    set buffer size for output
  1201. SO_RCVBUF    set buffer size for input
  1202. SO_TYPE    get the type of the socket (get only)
  1203. SO_ERROR    get and clear error on the socket (get only)
  1204. X.fi
  1205. X.RE
  1206. X.PP
  1207. SO_SNDBUF
  1208. and
  1209. SO_RCVBUF
  1210. are options to adjust the normal
  1211. buffer sizes allocated for output and input buffers, respectively.
  1212. The buffer size may be increased for high-volume connections,
  1213. or may be decreased to limit the possible backlog of incoming data.
  1214. The system places an absolute limit on these values.
  1215. X.PP
  1216. SO_TYPE
  1217. and
  1218. SO_ERROR
  1219. are options used only with
  1220. X.IR mc_getsockopt .
  1221. SO_TYPE
  1222. returns the type of the socket, such as
  1223. SOCK_STREAM;
  1224. it is useful for servers that inherit sockets on startup.
  1225. SO_ERROR
  1226. returns any pending error on the socket and clears
  1227. the error status.
  1228. It may be used to check for asynchronous errors on connected
  1229. datagram sockets or for other asynchronous errors.
  1230. X.SH COMPATIBILITY
  1231. The
  1232. X.I mc_getsockopt
  1233. and
  1234. X.I mc_setsockopt
  1235. calls emulate the
  1236. X.IR getsockopt (2)
  1237. and
  1238. X.IR setsockopt (2)
  1239. system calls for multicast socket descriptors created with the
  1240. X.IR mc_socket (2)
  1241. call.
  1242. See the manual pages for
  1243. X.IR getsockopt (2)
  1244. and
  1245. X.IR setsockopt (2)
  1246. for a description of the emulated semantics.
  1247. X.I Mc_getsockopt
  1248. and
  1249. X.I mc_setsockopt
  1250. do not provide any different semantics from
  1251. X.IR getsockopt (2)
  1252. and
  1253. X.IR setsockopt (2).
  1254. X.SH "RETURN VALUES"
  1255. Upon successful completion, a value of 0 is returned.
  1256. Otherwise, a value of -1 is returned and the global integer variable
  1257. X.I errno
  1258. is set to indicate the error.
  1259. X.SH ERRORS
  1260. See the manual page for
  1261. X.IR getsockopt (2)
  1262. for a detailed list of errors associated with the general
  1263. X.IR getsockopt (2)
  1264. and
  1265. X.IR setsockopt (2)
  1266. system calls.
  1267. X.I Mc_getsockopt
  1268. and
  1269. X.I mc_setsockopt
  1270. themselves will fail if:
  1271. X.TP 20
  1272. X[EBADF]
  1273. X.I S
  1274. is not a valid multicast socket descriptor as returned by
  1275. X.IR mc_socket (2).
  1276. X.TP 20
  1277. X[EIO]
  1278. The socket state has become corrupted.  This is an artifact of a
  1279. client/server implementation of the multicast communication system.
  1280. X.TP 20
  1281. X[ENOPROTOOPT]
  1282. The option is unknown at the level indicated.
  1283. X.SH "SEE ALSO"
  1284. X.IR getsockopt (2),
  1285. X.IR mc_fcntl (2),
  1286. X.IR mc_ioctl (2),
  1287. X.IR mc_socket (2),
  1288. X.IR mcast (4)
  1289. X.SH STANDARDS
  1290. There are no current standards that address multicast communication.
  1291. The software described in this manual page is experimental and subject
  1292. to change at any time.
  1293. END_OF_FILE
  1294. if test 6401 -ne `wc -c <'man/mc_getsockopt.2'`; then
  1295.     echo shar: \"'man/mc_getsockopt.2'\" unpacked with wrong size!
  1296. fi
  1297. # end of 'man/mc_getsockopt.2'
  1298. fi
  1299. if test -f 'man/mc_read.2' -a "${1}" != "-c" ; then 
  1300.   echo shar: Will not clobber existing file \"'man/mc_read.2'\"
  1301. else
  1302. echo shar: Extracting \"'man/mc_read.2'\" \(5043 characters\)
  1303. sed "s/^X//" >'man/mc_read.2' <<'END_OF_FILE'
  1304. X.\" Copyright (c) 1992 The Regents of the University of California.
  1305. X.\" All rights reserved.
  1306. X.\"
  1307. X.\" Redistribution and use in source and binary forms, with or without
  1308. X.\" modification, are permitted provided that the following conditions
  1309. X.\" are met:
  1310. X.\" 1. Redistributions of source code must retain the above copyright
  1311. X.\"    notice, this list of conditions and the following disclaimer.
  1312. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1313. X.\"    notice, this list of conditions and the following disclaimer in the
  1314. X.\"    documentation and/or other materials provided with the distribution.
  1315. X.\" 3. All advertising materials mentioning features or use of this software
  1316. X.\"    must display the following acknowledgement:
  1317. X.\"    This product includes software developed by the University of
  1318. X.\"    California, Lawrence Livermore National Laboratory and its
  1319. X.\"    contributors.
  1320. X.\" 4. Neither the name of the University nor the names of its contributors
  1321. X.\"    may be used to endorse or promote products derived from this software
  1322. X.\"    without specific prior written permission.
  1323. X.\"
  1324. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1325. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1326. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1327. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1328. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1329. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1330. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1331. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1332. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1333. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1334. X.\" SUCH DAMAGE.
  1335. X.\"
  1336. X.de Hd
  1337. X.ds Dt \\$4
  1338. X..
  1339. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_read.2,v 1.3 93/01/16 20:01:48 casey Exp $
  1340. X.TH MC_READ 2 \*(Dt
  1341. X.SH NAME
  1342. mc_read, mc_readv \- read input from a multicast socket
  1343. X.SH SYNOPSIS
  1344. X.nf
  1345. X.ft B
  1346. X#include <unistd.h>
  1347. X#include <sys/types.h>
  1348. X#include <sys/uio.h>
  1349. X#include <sys/socket.h>
  1350. X#include <netmcast/mcast.h>
  1351. X
  1352. int
  1353. mc_read(int s, void *buf, size_t len)
  1354. X
  1355. int
  1356. mc_readv(int s, const struct iovec *iov, int iovcnt)
  1357. X.ft P
  1358. X.fi
  1359. X.SH DESCRIPTION
  1360. X.I Mc_read
  1361. attempts to read
  1362. X.I len
  1363. bytes of data from the object referenced by the multicast socket descriptor
  1364. X.I s
  1365. into the buffer pointed to by
  1366. X.IR buf .
  1367. X.I Mc_readv
  1368. performs the same action, but scatters the input data
  1369. into the 
  1370. X.I iovcnt
  1371. buffers specified by the members of the
  1372. X.I iov
  1373. array: iov[0], iov[1], ..., iov[iovcnt\|\-\|1].
  1374. The multicast socket
  1375. X.I s
  1376. must be bound before either
  1377. X.I mc_read
  1378. or
  1379. X.I mc_readv
  1380. can be used.
  1381. X.PP
  1382. XFor 
  1383. X.IR mc_readv ,
  1384. the 
  1385. X.I iovec
  1386. structure is defined as
  1387. X.PP
  1388. X.RS
  1389. X.nf
  1390. X.ta \w'struct'u +\w'caddr_tXXXX'u
  1391. struct iovec {
  1392. X    caddr_t    iov_base;
  1393. X    int    iov_len;
  1394. X};
  1395. X.DT
  1396. X.fi
  1397. X.RE
  1398. X.PP
  1399. XEach 
  1400. X.I iovec
  1401. entry specifies the base address and length of an area
  1402. in memory where data should be placed. 
  1403. X.I Mc_readv
  1404. will always fill an area completely before proceeding
  1405. to the next.
  1406. X.PP
  1407. Upon successful completion,
  1408. X.I mc_read
  1409. and
  1410. X.I mc_readv
  1411. return the number of bytes actually read and placed in the buffer.
  1412. The system guarantees to read the number of bytes requested if
  1413. the descriptor references a normal file that has that many bytes left
  1414. before the end-of-file, but in no other case.
  1415. X.SH COMPATIBILITY
  1416. The
  1417. X.I mc_read
  1418. and
  1419. X.I mc_readv
  1420. calls emulate the
  1421. X.IR read (2)
  1422. and
  1423. X.IR readv (2)
  1424. system calls for multicast socket descriptors created with the
  1425. X.IR mc_socket (2)
  1426. call.
  1427. See the manual pages for
  1428. X.IR read (2)
  1429. and
  1430. X.IR readv (2)
  1431. for a description of the emulated semantics.
  1432. X.I Mc_read
  1433. and
  1434. X.I mc_readv
  1435. do not provide any different semantics from
  1436. X.IR read (2)
  1437. and
  1438. X.IR readv (2).
  1439. X.SH "RETURN VALUES"
  1440. If successful, the
  1441. number of bytes actually read is returned. Upon reading end-of-file,
  1442. zero is returned.  (This happens when
  1443. X.IR mc_shutdown (2)
  1444. has been used to shutdown the receive half of the multicast socket.)
  1445. Otherwise, a -1 is returned and the global variable
  1446. X.I errno
  1447. is set to indicate the error.
  1448. X.SH ERRORS
  1449. See the manual pages for
  1450. X.IR read (2)
  1451. and
  1452. X.IR readv (2)
  1453. for a detailed list of errors associated with the general
  1454. X.IR read (2)
  1455. and
  1456. X.IR readv (2)
  1457. system calls.
  1458. X.I Mc_read
  1459. and
  1460. X.I mc_readv
  1461. themselves will fail if:
  1462. X.TP 20
  1463. X[EBADF]
  1464. X.I S
  1465. is not a valid multicast socket descriptor as returned by
  1466. X.IR mc_socket (2).
  1467. X.TP 20
  1468. X[EIO]
  1469. The socket state has become corrupted.  This is an artifact of a
  1470. client/server implementation of the multicast communication system.
  1471. X.TP 20
  1472. X[EPIPE]
  1473. No name has been bound to the multicast socket yet.
  1474. X.TP 20
  1475. X[EAGAIN]
  1476. The file was marked for non-blocking I/O,
  1477. and no data could be read immediately.
  1478. X.SH "SEE ALSO"
  1479. X.IR mc_socket (2),
  1480. X.IR mcast (4),
  1481. X.IR read (2),
  1482. X.IR select (2)
  1483. X.SH STANDARDS
  1484. There are no current standards that address multicast communication.
  1485. The software described in this manual page is experimental and subject
  1486. to change at any time.
  1487. END_OF_FILE
  1488. if test 5043 -ne `wc -c <'man/mc_read.2'`; then
  1489.     echo shar: \"'man/mc_read.2'\" unpacked with wrong size!
  1490. fi
  1491. # end of 'man/mc_read.2'
  1492. fi
  1493. if test -f 'man/mc_recv.2' -a "${1}" != "-c" ; then 
  1494.   echo shar: Will not clobber existing file \"'man/mc_recv.2'\"
  1495. else
  1496. echo shar: Extracting \"'man/mc_recv.2'\" \(5752 characters\)
  1497. sed "s/^X//" >'man/mc_recv.2' <<'END_OF_FILE'
  1498. X.\" Copyright (c) 1992 The Regents of the University of California.
  1499. X.\" All rights reserved.
  1500. X.\"
  1501. X.\" Redistribution and use in source and binary forms, with or without
  1502. X.\" modification, are permitted provided that the following conditions
  1503. X.\" are met:
  1504. X.\" 1. Redistributions of source code must retain the above copyright
  1505. X.\"    notice, this list of conditions and the following disclaimer.
  1506. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1507. X.\"    notice, this list of conditions and the following disclaimer in the
  1508. X.\"    documentation and/or other materials provided with the distribution.
  1509. X.\" 3. All advertising materials mentioning features or use of this software
  1510. X.\"    must display the following acknowledgement:
  1511. X.\"    This product includes software developed by the University of
  1512. X.\"    California, Lawrence Livermore National Laboratory and its
  1513. X.\"    contributors.
  1514. X.\" 4. Neither the name of the University nor the names of its contributors
  1515. X.\"    may be used to endorse or promote products derived from this software
  1516. X.\"    without specific prior written permission.
  1517. X.\"
  1518. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1519. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1520. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1521. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1522. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1523. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1524. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1525. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1526. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1527. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1528. X.\" SUCH DAMAGE.
  1529. X.\"
  1530. X.de Hd
  1531. X.ds Dt \\$4
  1532. X..
  1533. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_recv.2,v 1.1 92/10/16 18:23:04 casey Exp $
  1534. X.TH MC_RECV 2 \*(Dt
  1535. X.SH NAME
  1536. mc_recv, mc_recvfrom \- receive a message from a multicast socket
  1537. X.SH SYNOPSIS
  1538. X.nf
  1539. X.ft B
  1540. X#include <sys/types.h>
  1541. X#include <sys/socket.h>
  1542. X#include <netmcast/mcast.h>
  1543. X
  1544. int
  1545. mc_recv(int s, void *buf, int len, int flags)
  1546. X
  1547. int
  1548. mc_recvfrom(int s, void *buf, int len, int flags,
  1549. X            struct sockaddr *from, int *fromlen)
  1550. X.ft P
  1551. X.fi
  1552. X.SH DESCRIPTION
  1553. X.I Mc_recv
  1554. and
  1555. X.I mc_recvfrom
  1556. are used to receive messages from a multicast socket.
  1557. The multicast socket
  1558. X.I s
  1559. must be bound before either
  1560. X.I mc_recv
  1561. or
  1562. X.I mc_recvfrom
  1563. can be used.
  1564. X.PP
  1565. XFor
  1566. X.IR mc_recvfrom ,
  1567. if
  1568. X.I from
  1569. is non-NULL, the source address of the message is filled in.
  1570. X.I Fromlen
  1571. is a value-result parameter, initialized to the size of
  1572. the buffer associated with
  1573. X.IR from ,
  1574. and modified on return to indicate the actual size of the
  1575. address stored there.
  1576. The
  1577. X.I recv
  1578. is identical to
  1579. X.I recvfrom
  1580. with a NULL
  1581. X.I from
  1582. parameter.
  1583. As it is redundant, it may not be supported in future releases.
  1584. X.PP
  1585. X.I Buf
  1586. specifies where the received data should be stored in memory and
  1587. X.I len
  1588. specifies the amount of data requested.
  1589. The amount of data actually read into
  1590. X.I buf
  1591. is returned.
  1592. If a message is too long to fit in the supplied buffer,
  1593. excess bytes may be discarded depending on the type of socket
  1594. the message is received from (see
  1595. X.IR mc_socket (2).
  1596. X.PP
  1597. If no messages are available at the socket, the
  1598. receive call waits for a message to arrive, unless
  1599. the socket is non-blocking (see
  1600. X.IR mc_fcntl (2)
  1601. in which case the value
  1602. X-1 is returned and the external variable
  1603. X.I errno
  1604. set to
  1605. XEAGAIN.
  1606. The
  1607. X.IR select (2)
  1608. call may be used to determine when more data arrive.
  1609. X.PP
  1610. The
  1611. X.I flags
  1612. argument to a recv call is formed by \fIor\fPing
  1613. one or more of the values:
  1614. X.PP
  1615. X.RS
  1616. X.nf
  1617. MSG_PEEK    peek at incoming message
  1618. X.fi
  1619. X.RE
  1620. X.PP
  1621. The MSG_PEEK flag causes the receive operation to return data
  1622. from the beginning of the receive queue without removing that
  1623. data from the queue.
  1624. Thus, a subsequent receive call will return the same data.
  1625. X.SH COMPATIBILITY
  1626. The
  1627. X.I mc_recv
  1628. and
  1629. X.I mc_recvfrom
  1630. calls emulate the
  1631. X.IR recv (2)
  1632. and
  1633. X.IR recvfrom (2)
  1634. system calls for multicast socket descriptors created with the
  1635. X.IR mc_socket (2)
  1636. call.
  1637. See the manual pages for
  1638. X.IR recv (2)
  1639. and
  1640. X.IR recvfrom (2)
  1641. for a description of the emulated semantics.
  1642. X.I Mc_recv
  1643. and
  1644. X.I mc_recvfrom
  1645. do not provide any different semantics from
  1646. X.IR recv (2)
  1647. and
  1648. X.IR recvfrom (2).
  1649. X.SH "RETURN VALUES"
  1650. If successful, the
  1651. number of bytes actually received is returned.  Upon reading end-of-file,
  1652. zero is returned.  (This happens when
  1653. X.IR mc_shutdown (2)
  1654. has been used to shutdown the receive half of the multicast socket.)
  1655. Otherwise, a -1 is returned and the global variable
  1656. X.I errno
  1657. is set to indicate the error.
  1658. X.SH ERRORS
  1659. See the manual pages for
  1660. X.IR recv (2)
  1661. and
  1662. X.IR recvfrom (2)
  1663. for a detailed list of errors associated with the general
  1664. X.IR recv (2)
  1665. and
  1666. X.IR recvfrom (2)
  1667. system calls.
  1668. X.I Mc_recv
  1669. and
  1670. X.I mc_recvfrom
  1671. themselves will fail if:
  1672. X.TP 20
  1673. X[EBADF]
  1674. X.I S
  1675. is not a valid multicast socket descriptor as returned by
  1676. X.IR mc_socket (2).
  1677. X.TP 20
  1678. X[EIO]
  1679. The socket state has become corrupted.  This is an artifact of a
  1680. client/server implementation of the multicast communication system.
  1681. X.TP 20
  1682. X[EPIPE]
  1683. No name has been bound to the multicast socket yet.
  1684. X.TP 20
  1685. X[EINVAL]
  1686. X.I Fromlen
  1687. is less than
  1688. X.IR sizeof ( "struct sockaddr_mcast" ).
  1689. X.TP 20
  1690. X[EAGAIN]
  1691. The file was marked for non-blocking I/O,
  1692. and no data could be read immediately.
  1693. X.SH "SEE ALSO"
  1694. X.IR mc_fcntl (2),
  1695. X.IR mc_read (2),
  1696. X.IR mc_getsockopt (2),
  1697. X.IR mc_socket (2),
  1698. X.IR mcast (4),
  1699. X.IR recv (2),
  1700. X.IR select (2)
  1701. X.SH STANDARDS
  1702. There are no current standards that address multicast communication.
  1703. The software described in this manual page is experimental and subject
  1704. to change at any time.
  1705. END_OF_FILE
  1706. if test 5752 -ne `wc -c <'man/mc_recv.2'`; then
  1707.     echo shar: \"'man/mc_recv.2'\" unpacked with wrong size!
  1708. fi
  1709. # end of 'man/mc_recv.2'
  1710. fi
  1711. if test -f 'man/mc_send.2' -a "${1}" != "-c" ; then 
  1712.   echo shar: Will not clobber existing file \"'man/mc_send.2'\"
  1713. else
  1714. echo shar: Extracting \"'man/mc_send.2'\" \(5986 characters\)
  1715. sed "s/^X//" >'man/mc_send.2' <<'END_OF_FILE'
  1716. X.\" Copyright (c) 1992 The Regents of the University of California.
  1717. X.\" All rights reserved.
  1718. X.\"
  1719. X.\" Redistribution and use in source and binary forms, with or without
  1720. X.\" modification, are permitted provided that the following conditions
  1721. X.\" are met:
  1722. X.\" 1. Redistributions of source code must retain the above copyright
  1723. X.\"    notice, this list of conditions and the following disclaimer.
  1724. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1725. X.\"    notice, this list of conditions and the following disclaimer in the
  1726. X.\"    documentation and/or other materials provided with the distribution.
  1727. X.\" 3. All advertising materials mentioning features or use of this software
  1728. X.\"    must display the following acknowledgement:
  1729. X.\"    This product includes software developed by the University of
  1730. X.\"    California, Lawrence Livermore National Laboratory and its
  1731. X.\"    contributors.
  1732. X.\" 4. Neither the name of the University nor the names of its contributors
  1733. X.\"    may be used to endorse or promote products derived from this software
  1734. X.\"    without specific prior written permission.
  1735. X.\"
  1736. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1737. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1738. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1739. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1740. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1741. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1742. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1743. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1744. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1745. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1746. X.\" SUCH DAMAGE.
  1747. X.\"
  1748. X.de Hd
  1749. X.ds Dt \\$4
  1750. X..
  1751. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_send.2,v 1.2 93/01/16 20:02:26 casey Exp $
  1752. X.TH MC_SEND 2 \*(Dt
  1753. X.SH NAME
  1754. mc_send, mc_sendto \- send a message to a multicast socket
  1755. X.SH SYNOPSIS
  1756. X.nf
  1757. X.ft B
  1758. X#include <sys/types.h>
  1759. X#include <sys/socket.h>
  1760. X#include <netmcast/mcast.h>
  1761. X
  1762. int
  1763. mc_send(int s, const void *buf, int len, int flags)
  1764. X
  1765. int
  1766. mc_sendto(int s, const void *buf, int len, int flags,
  1767. X          const struct sockaddr *to, int tolen)
  1768. X.ft P
  1769. X.fi
  1770. X.SH DESCRIPTION
  1771. X.I Mc_send
  1772. and
  1773. X.I mc_sendto
  1774. are used to transmit messages on a multicast socket.
  1775. The multicast socket
  1776. X.I s
  1777. must be bound before either
  1778. X.I mc_send
  1779. can be used.
  1780. X.PP
  1781. If
  1782. X.I mc_sendto
  1783. is used on an unbound multicast socket,
  1784. X.I mc_sendto
  1785. will automatically bind a name to the socket using the multicast group
  1786. specified in
  1787. X.I to
  1788. a new, unique local group member address (see
  1789. X.IR mcast_newaddr (3)).
  1790. The remote member association will be set to MCADDR_BROADCAST.  To change
  1791. the remote member association see
  1792. X.IR mc_connect (2).
  1793. X.PP
  1794. XFor
  1795. X.IR mc_sendto ,
  1796. if
  1797. X.I to
  1798. is non-NULL, it contains the remote group member address that the message
  1799. it to be sent to.
  1800. X.I Tolen
  1801. specifies the length of
  1802. X.IR to .
  1803. The
  1804. X.I send
  1805. is identical to
  1806. X.I sendto
  1807. with a NULL
  1808. X.I to
  1809. parameter.
  1810. As it is redundant, it may not be supported in future releases.
  1811. X.PP
  1812. X.I Buf
  1813. specifies where the data to be sent is located in memory and
  1814. X.I len
  1815. specifies the amount of data to be sent.
  1816. If the message is too long to pass atomically through the
  1817. underlying protocol, the error
  1818. XEMSGSIZE
  1819. is returned, and
  1820. the message is not transmitted.
  1821. X.PP
  1822. If no messages space is available at the socket to hold
  1823. the message to be transmitted, then
  1824. X.I mc_send
  1825. normally blocks, unless the socket has been placed in
  1826. non-blocking I/O mode (see
  1827. X.IR mc_fcntl (2))
  1828. in which case the value
  1829. X-1 is returned and the external variable
  1830. X.I errno
  1831. set to
  1832. XEAGAIN.
  1833. The
  1834. X.IR select (2)
  1835. call may be used to determine when it is possible to
  1836. send more data.
  1837. X.PP
  1838. The
  1839. X.I flags
  1840. parameter may include one or more of the following:
  1841. X.PP
  1842. X.RS
  1843. X.nf
  1844. no flags currently supported
  1845. X.fi
  1846. X.RE
  1847. X.PP
  1848. X.SH COMPATIBILITY
  1849. The
  1850. X.I mc_send
  1851. and
  1852. X.I mc_sendto
  1853. calls emulate the
  1854. X.IR send (2)
  1855. and
  1856. X.IR sendto (2)
  1857. system calls for multicast socket descriptors created with the
  1858. X.IR mc_socket (2)
  1859. call.
  1860. See the manual pages for
  1861. X.IR send (2)
  1862. and
  1863. X.IR sendto (2)
  1864. for a description of the emulated semantics.
  1865. X.I Mc_send
  1866. and
  1867. X.I mc_sendto
  1868. do not provide any different semantics from
  1869. X.IR send (2)
  1870. and
  1871. X.IR sendto (2).
  1872. X.SH "RETURN VALUES"
  1873. If successful, the number of bytes actually written is returned.
  1874. Otherwise, a -1 is returned and the global variable
  1875. X.I errno
  1876. is set to indicate the error.
  1877. X.SH ERRORS
  1878. See the manual pages for
  1879. X.IR send (2)
  1880. and
  1881. X.IR sendto (2)
  1882. for a detailed list of errors associated with the general
  1883. X.IR send (2)
  1884. and
  1885. X.IR sendto (2)
  1886. system calls.
  1887. X.I Mc_send
  1888. and
  1889. X.I mc_sendto
  1890. themselves will fail if:
  1891. X.TP 20
  1892. X[EBADF]
  1893. X.I S
  1894. is not a valid multicast socket descriptor as returned by
  1895. X.IR mc_socket (2).
  1896. X.TP 20
  1897. X[EIO]
  1898. The socket state has become corrupted.  This is an artifact of a
  1899. client/server implementation of the multicast communication system.
  1900. X.TP 20
  1901. X[EPIPE]
  1902. No name has been bound to the multicast socket yet.
  1903. X.TP 20
  1904. X[EPIPE]
  1905. X.I Mc_shutdown
  1906. was used to shutdown sending on the multicast socket.  All further attempts
  1907. to write on the multicast socket will return EPIPE.
  1908. X.TP 20
  1909. X[EINVAL]
  1910. X.I Tolen
  1911. is less than
  1912. X.IR sizeof ( "struct sockaddr_mcast" ).
  1913. X.TP 20
  1914. X[EINVAL]
  1915. X.I To
  1916. specified a remote group member address of MCADDR_ANY.
  1917. X.TP 20
  1918. X[EAFNOSUPPORT]
  1919. X.I To
  1920. specified an address family other than AF_MCAST.
  1921. X.TP 20
  1922. X[EISCONN]
  1923. X.I S
  1924. has been bound and
  1925. X.I to
  1926. specified a multicast group different from that already bound to
  1927. X.IR s .
  1928. X.TP 20
  1929. X[EAGAIN]
  1930. The file was marked for non-blocking I/O,
  1931. and no data could be sent immediately.
  1932. X.SH "SEE ALSO"
  1933. X.IR mc_fcntl (2),
  1934. X.IR mc_getsockopt (2),
  1935. X.IR mc_socket (2),
  1936. X.IR mc_write (2),
  1937. X.IR mcast (4),
  1938. X.IR send (2),
  1939. X.IR select (2)
  1940. X.SH STANDARDS
  1941. There are no current standards that address multicast communication.
  1942. The software described in this manual page is experimental and subject
  1943. to change at any time.
  1944. END_OF_FILE
  1945. if test 5986 -ne `wc -c <'man/mc_send.2'`; then
  1946.     echo shar: \"'man/mc_send.2'\" unpacked with wrong size!
  1947. fi
  1948. # end of 'man/mc_send.2'
  1949. fi
  1950. if test -f 'man/mc_socket.2' -a "${1}" != "-c" ; then 
  1951.   echo shar: Will not clobber existing file \"'man/mc_socket.2'\"
  1952. else
  1953. echo shar: Extracting \"'man/mc_socket.2'\" \(5520 characters\)
  1954. sed "s/^X//" >'man/mc_socket.2' <<'END_OF_FILE'
  1955. X.\" Copyright (c) 1992 The Regents of the University of California.
  1956. X.\" All rights reserved.
  1957. X.\"
  1958. X.\" Redistribution and use in source and binary forms, with or without
  1959. X.\" modification, are permitted provided that the following conditions
  1960. X.\" are met:
  1961. X.\" 1. Redistributions of source code must retain the above copyright
  1962. X.\"    notice, this list of conditions and the following disclaimer.
  1963. X.\" 2. Redistributions in binary form must reproduce the above copyright
  1964. X.\"    notice, this list of conditions and the following disclaimer in the
  1965. X.\"    documentation and/or other materials provided with the distribution.
  1966. X.\" 3. All advertising materials mentioning features or use of this software
  1967. X.\"    must display the following acknowledgement:
  1968. X.\"    This product includes software developed by the University of
  1969. X.\"    California, Lawrence Livermore National Laboratory and its
  1970. X.\"    contributors.
  1971. X.\" 4. Neither the name of the University nor the names of its contributors
  1972. X.\"    may be used to endorse or promote products derived from this software
  1973. X.\"    without specific prior written permission.
  1974. X.\"
  1975. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1976. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1977. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1978. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1979. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1980. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1981. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1982. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1983. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1984. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1985. X.\" SUCH DAMAGE.
  1986. X.\"
  1987. X.de Hd
  1988. X.ds Dt \\$4
  1989. X..
  1990. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mc_socket.2,v 1.3 93/01/16 20:03:14 casey Exp $
  1991. X.TH MC_SOCKET 2 \*(Dt
  1992. X.SH NAME
  1993. mc_socket \- create a endpoint for multicast communication
  1994. X.SH SYNOPSIS
  1995. X.nf
  1996. X.ft B
  1997. X#include <sys/types.h>
  1998. X#include <sys/socket.h>
  1999. X#include <netmcast/mcast.h>
  2000. X
  2001. int
  2002. mc_socket(int domain, int type, int protocol)
  2003. X.ft P
  2004. X.fi
  2005. X.SH DESCRIPTION
  2006. X.I Mc_socket
  2007. creates an endpoint for multicast communication and returns a descriptor.
  2008. The
  2009. X.I domain
  2010. parameter specifies a communications domain within which
  2011. communication will take place; this selects the protocol family
  2012. which should be used.
  2013. These families are defined in the include file
  2014. X.IR <netmcast/mcast.h> .
  2015. The currently understood formats are
  2016. X.PP
  2017. X.ta \w'SOCK_SEQPACKETXXX'u
  2018. X.RS
  2019. X.nf
  2020. PF_MCAST    multicast protocols
  2021. PF_AMCAST    atomic (globally ordered) multicast protocols
  2022. X.fi
  2023. X.RE
  2024. X.PP
  2025. The socket has the indicated
  2026. X.IR type ,
  2027. which specifies the semantics of communication.  Currently
  2028. defined types are:
  2029. X.PP
  2030. X.RS
  2031. X.nf
  2032. SOCK_DGRAM    unsequenced, unreliable packet stream
  2033. SOCK_RDM    unsequenced, reliable packet stream
  2034. SOCK_SEQPACKET    sequenced, reliable packet stream
  2035. SOCK_STREAM    sequenced, reliable byte stream
  2036. X.fi
  2037. X.RE
  2038. X.DT
  2039. X.PP
  2040. XFor PF_AMCAST, only SOCK_SEQPACKET and SOCK_STREAM are supported.  See
  2041. X.IR mcast (4)
  2042. for a description of these families and types.
  2043. X.PP
  2044. The
  2045. X.Fa protocol
  2046. specifies a particular protocol to be used with the socket.
  2047. Normally only a single protocol exists to support a particular
  2048. socket type within a given protocol family.  However, it is possible
  2049. that many protocols may exist, in which case a particular protocol
  2050. must be specified in this manner.  The protocol number to use is
  2051. particular to the \*(lqcommunication domain\*(rq in which communication
  2052. is to take place; see
  2053. X.IR protocols (5).
  2054. XFor
  2055. X.I mc_socket
  2056. only protocol
  2057. X.B 0
  2058. is supported for any of the types.
  2059. X.SH COMPATIBILITY
  2060. The
  2061. X.I mc_socket
  2062. call emulates the
  2063. X.IR socket (2)
  2064. system call for multicast socket descriptors created with the
  2065. X.IR mc_socket (2)
  2066. call.
  2067. See the manual page for
  2068. X.IR socket (2)
  2069. for a description of the emulated semantics.
  2070. X.I Mc_socket
  2071. does not provide any different semantics from
  2072. X.IR socket (2).
  2073. X.SH "RETURN VALUES"
  2074. A -1 is returned if an error occurs, otherwise the return
  2075. value is a descriptor referencing the multicast socket.
  2076. X.SH ERRORS
  2077. See the manual page for
  2078. X.IR socket (2)
  2079. for a detailed list of errors associated with the general
  2080. X.IR socket (2)
  2081. system call.
  2082. X.I Mc_socket
  2083. itself will fail if:
  2084. X.TP 20
  2085. X[EPFNOSUPPORT]
  2086. The
  2087. X.I domain
  2088. specified is not
  2089. PF_MCAST.
  2090. X.TP 20
  2091. X[EPROTONOSUPPORT]
  2092. X.I Type
  2093. is not one of SOCK_DGRAM, SOCK_RDM, SOCK_SEQPACKET, or SOCK_STREAM.
  2094. X.TP 20
  2095. X[EPROTONOSUPPORT]
  2096. The
  2097. X.I protocol
  2098. is not
  2099. X.BR 0 .
  2100. X.TP 20
  2101. X[EMFILE]
  2102. The fixed size multicast socket state space was exceeded.  So shoot me
  2103. for putting in a fixed limit.  This is just an experimental package to
  2104. demonstrate proof of concept ...
  2105. X.TP 20
  2106. X[EHOSTUNREACH]
  2107. The address couldn't be determined of the machine running the
  2108. multicast communication server.  This is an artifact of a
  2109. client/server implementation of the multicast communication system.
  2110. X.SH SEE ALSO
  2111. X.IR mcast (4),
  2112. X.IR mcast_getgroupbyname (3),
  2113. X.IR mcast_newaddr (3),
  2114. X.IR mcast_sopen (3),
  2115. X.IR mc_bind (2),
  2116. X.IR mc_close (2),
  2117. X.IR mc_connect (2),
  2118. X.IR mc_fcntl (2),
  2119. X.IR mc_getsockname (2),
  2120. X.IR mc_getsockopt (2),
  2121. X.IR mc_ioctl (2),
  2122. X.IR mc_read (2),
  2123. X.IR mc_recv (2),
  2124. X.IR mc_send (2),
  2125. X.IR mc_shutdown (2),
  2126. X.IR mc_write (2),
  2127. X.IR select (2),
  2128. X.IR socket (2)
  2129. X.SH STANDARDS
  2130. There are no current standards that address multicast communication.
  2131. The software described in this manual page is experimental and subject
  2132. to change at any time.
  2133. END_OF_FILE
  2134. if test 5520 -ne `wc -c <'man/mc_socket.2'`; then
  2135.     echo shar: \"'man/mc_socket.2'\" unpacked with wrong size!
  2136. fi
  2137. # end of 'man/mc_socket.2'
  2138. fi
  2139. if test -f 'man/mcast.4' -a "${1}" != "-c" ; then 
  2140.   echo shar: Will not clobber existing file \"'man/mcast.4'\"
  2141. else
  2142. echo shar: Extracting \"'man/mcast.4'\" \(13604 characters\)
  2143. sed "s/^X//" >'man/mcast.4' <<'END_OF_FILE'
  2144. X.\" Copyright (c) 1992 The Regents of the University of California.
  2145. X.\" All rights reserved.
  2146. X.\"
  2147. X.\" Redistribution and use in source and binary forms, with or without
  2148. X.\" modification, are permitted provided that the following conditions
  2149. X.\" are met:
  2150. X.\" 1. Redistributions of source code must retain the above copyright
  2151. X.\"    notice, this list of conditions and the following disclaimer.
  2152. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2153. X.\"    notice, this list of conditions and the following disclaimer in the
  2154. X.\"    documentation and/or other materials provided with the distribution.
  2155. X.\" 3. All advertising materials mentioning features or use of this software
  2156. X.\"    must display the following acknowledgement:
  2157. X.\"    This product includes software developed by the University of
  2158. X.\"    California, Lawrence Livermore National Laboratory and its
  2159. X.\"    contributors.
  2160. X.\" 4. Neither the name of the University nor the names of its contributors
  2161. X.\"    may be used to endorse or promote products derived from this software
  2162. X.\"    without specific prior written permission.
  2163. X.\"
  2164. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2165. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2166. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2167. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2168. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2169. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2170. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2171. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2172. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2173. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2174. X.\" SUCH DAMAGE.
  2175. X.\"
  2176. X.de Hd
  2177. X.ds Dt \\$4
  2178. X..
  2179. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mcast.4,v 1.3 93/01/16 20:06:23 casey Exp $
  2180. X.TH MCAST 4 \*(Dt
  2181. X.SH NAME
  2182. mcast \- multicast protocol
  2183. X.SH SYNOPSIS
  2184. X.nf
  2185. X.ft B
  2186. X#include <sys/types.h>
  2187. X#include <sys/socket.h>
  2188. X#include <netmcast/mcast.h>
  2189. X
  2190. int
  2191. mc_socket(int domain, int type, int protocol)
  2192. X.ft P
  2193. X.fi
  2194. X.SH DESCRIPTION
  2195. The multicast protocol families allow applications to communicate in a
  2196. broadcast-like manner with other applications.  Multicast would typically
  2197. be used by the parts of a distributed application.  The communication
  2198. style may be message or stream oriented; reliable or unreliable;
  2199. unsequenced, single source sequenced or globally sequenced (although not all
  2200. combinations are allowed; see below).
  2201. X.PP
  2202. Within each multicast communication domain, there are a large number of
  2203. potential multicast
  2204. X.IR groups .
  2205. When a message is sent to a multicast group, it will normally be received
  2206. by all applications which are subscribed to the group for reading.  An
  2207. important exception to this is the
  2208. X.IR "multicast unicast"
  2209. which is only sent to a particular multicast group
  2210. X.IR member .
  2211. Multicast unicasts can be performed either individually via
  2212. X.I mc_sendto
  2213. or set up as the normal state of affairs with
  2214. X.IR mc_connect .
  2215. X.PP
  2216. A multicast group can be thought of as a
  2217. X.I "virtual network"
  2218. which is some subset of connected physical networks.  Every multicast
  2219. group member is a process which executes on a node of the
  2220. virtual/physical network.  Each multicast group has an address unique
  2221. from all others within its communication domain and every member of a
  2222. multicast group has an address unique from all other members of that
  2223. multicast group.
  2224. X.PP
  2225. Multicast groups can be created on demand and discarded just as
  2226. easily.  One paradigm of operation is to treat multicast groups in much
  2227. the same way as UNIX shells treat pipes: i.e. a process creates
  2228. one or more multicast groups, forks one or more children, and passes the
  2229. multicast groups to the children for use in communicating among themselves.
  2230. X.I Well known
  2231. multicast groups are also possible.
  2232. X.PP
  2233. Connections to multicast groups are formed by calling
  2234. X.I mc_socket
  2235. to create a socket in one of the multicast protocol family domains and
  2236. then binding a multicast group name to the socket via
  2237. X.I mc_bind
  2238. X(though there are other ways to bind names).  Further details of the
  2239. multicast socket's operation can be specified with
  2240. X.I mc_setsockopt
  2241. and
  2242. X.IR mc_fcntl .
  2243. Once such a connection is formed, messages may be read and written via
  2244. X.I mc_read
  2245. and
  2246. X.I mc_write
  2247. X(and a few other variations).
  2248. While a multicast connection is alive,
  2249. X.IR select (2)
  2250. can be used to poll or block for input data or output buffer space
  2251. availability just as with other file descriptor types.  Finally a
  2252. connection can be dissolved via
  2253. X.IR mc_close .
  2254. X.PP
  2255. As mentioned above, once a multicast socket has been created with
  2256. X.IR mc_socket ,
  2257. a name must be bound to it before it can be used.  For multicast sockets,
  2258. this name consists of a multicast address family, group address and group
  2259. member address.
  2260. X.PP
  2261. X.RS
  2262. X.nf
  2263. X.ta \w'struct'u +\w'struct mc_addr;XXXX'u +\w'memberXXXX'u
  2264. struct sockaddr_mcast {
  2265. X    short    family;    /* AF_MCAST or AF_AMCAST */
  2266. X    struct mc_addr    group;    /* multicast group ID */
  2267. X    struct mc_addr    member;    /* multicast group member ID */
  2268. X};
  2269. X.DT
  2270. X.fi
  2271. X.RE
  2272. X.PP
  2273. The process of binding a name to a multicast socket corresponds
  2274. to joining a multicast group and choosing a unique multicast group member
  2275. identifier.
  2276. X.I Mc_bind
  2277. is used to bind names to multicast sockets.  If a socket hasn't had a
  2278. name bound to it, then an
  2279. X.I mc_connect (2)
  2280. or an
  2281. X.I mc_sendto (2)
  2282. will cause an implicit bind to take place.
  2283. Once a name has been bound to a multicast socket it may not be changed.
  2284. X.PP
  2285. Implicit in the above is the fact that a multicast socket can only be
  2286. connected to
  2287. X.I one
  2288. multicast group.  If an application wants to join more than one multicast
  2289. group, it must acquire a separate multicast socket for each group.
  2290. Multiplexing I/O activity between multiple multicast sockets and other
  2291. file descriptors can be managed with the
  2292. X.IR select (2)
  2293. call.
  2294. X.PP
  2295. Unlike other communication domains, reliable type sockets in the
  2296. multicast domain are not required to be in a
  2297. X.I connected
  2298. state before being used.  This is because there is no parallel to the
  2299. asymmetric client/server model of other domains.  When we speak of a
  2300. socket being
  2301. X.I connected
  2302. to a multicast group we mean that it is bound to a multicast group.  For
  2303. unreliable sockets, this merely means giving a name to the socket which
  2304. will be used for the source address of all out-going messages and to set
  2305. up a multicast listening filter.  For reliable sockets, naming a socket
  2306. also causes reliable communication transports to be set up with all hosts
  2307. on all directly connected networks which have processes connected to the
  2308. multicast group.
  2309. X.PP
  2310. The supported multicast protocol families are as follows:
  2311. X.ta \w'SOCK_SEQPACKETXXX'u
  2312. X.RS
  2313. X.nf
  2314. PF_MCAST    multicast protocols
  2315. PF_AMCAST    atomic (globally ordered) multicast protocols
  2316. X.fi
  2317. X.RE
  2318. The supported socket types in the multicast domains are as follows:
  2319. X.PP
  2320. X.RS
  2321. X.nf
  2322. SOCK_DGRAM    unsequenced, unreliable packet stream
  2323. SOCK_RDM    unsequenced, reliable packet stream
  2324. SOCK_SEQPACKET    sequenced, reliable packet stream
  2325. SOCK_STREAM    sequenced, reliable byte stream
  2326. X.fi
  2327. X.RE
  2328. X.DT
  2329. X.PP
  2330. XFor PF_AMCAST, only SOCK_SEQPACKET and SOCK_STREAM are supported.
  2331. X.PP
  2332. SOCK_DGRAM offers an unreliable, unsequenced, possibly duplicated
  2333. message-oriented communication channel to an application.  Only a best
  2334. effort will be made to get the message to the destination
  2335. application(s).
  2336. X.PP
  2337. In the multicast domains, the only difference between SOCK_RDM,
  2338. SOCK_SEQPACKET and SOCK_STREAM is in the presentation semantics offered
  2339. to an application.  They all reliably deliver data between multicast
  2340. peers without loss or duplication.  The receiving communication software
  2341. provides the reliably delivered data to the application as an unsequenced
  2342. message stream, a sequenced message stream or a byte stream.
  2343. X.PP
  2344. In the PF_MCAST domain, the sequencing offered by SOCK_SEQPACKET and
  2345. SOCK_STREAM is only with respect to the sender.  Different receivers may
  2346. see different message interleavings from multiple senders.
  2347. X.PP
  2348. In the PF_AMCAST protocol family, all messages on a multicast group will
  2349. be received in exactly the same order by all receivers.  That is, if one
  2350. member of multicast group
  2351. X.I G
  2352. receives message
  2353. X.I A
  2354. before message
  2355. X.IR B ,
  2356. X.I all
  2357. members of multicast group
  2358. X.I G
  2359. will receive message
  2360. X.I A
  2361. before message
  2362. X.IR B .
  2363. This is radically different from PF_MCAST in this respect and comes at a
  2364. price since message sequencing must be globally coordinated between all
  2365. members of a multicast group.  This semantic is useful for distributed
  2366. locking schemes and other similar distributed algorithms.
  2367. X.PP
  2368. XFor multicast sockets, each write operation defines a single logical
  2369. message and reads will not read across message boundaries.
  2370. XFor sockets with message presentation semantics
  2371. X(SOCK_SEQPACKET, SOCK_RDM, and SOCK_DGRAM),
  2372. if only part of a message is read, the
  2373. remainder is discarded.
  2374. XFor SOCK_STREAM sockets, if only part of a message is read, the remainder
  2375. is left available for future read operations.
  2376. X.SH EXAMPLES
  2377. In the following examples, all error detection and recovery have been
  2378. omitted in the interest of brevity and clarity.  Real applications would
  2379. test the results of all system calls.
  2380. X.PP
  2381. What example set would be complete without \*(lqhello world?\*(rq
  2382. The following example opens a connection to the
  2383. X.B hello-world-group
  2384. and sends the message
  2385. X.B "hello world!"
  2386. onto it.
  2387. X.PP
  2388. X.RS
  2389. X.nf
  2390. int s;
  2391. X
  2392. s = mcast_sopen("hello-world-group", PF_MCAST, SOCK_STREAM, O_WRONLY);
  2393. X(void)mc_write(s, "hello world!\\n", 13);
  2394. X(void)mc_close(s);
  2395. X.fi
  2396. X.RE
  2397. X.PP
  2398. You can think of the next example as one half of the popular
  2399. X.IR cat (1)
  2400. program.  It opens a connection to a multicast group, reads messages
  2401. from that group and outputs them onto standard output, and terminates when
  2402. it reads a zero length message.
  2403. X.PP
  2404. X.RS
  2405. X.nf
  2406. int s;
  2407. char *group = "...";
  2408. X
  2409. s = mcast_sopen(group, PF_MCAST, SOCK_STREAM, O_RDONLY);
  2410. for (;;) {
  2411. X    char buf[1024];
  2412. X    int nread, nwrite;
  2413. X
  2414. X    nread = mc_read(s, buf, sizeof(buf));
  2415. X    if (nread == 0)
  2416. X        break;
  2417. X    (void)write(STDOUT_FILENO, buf, nread);
  2418. X}
  2419. X(void)mc_close(s);
  2420. X.fi
  2421. X.RE
  2422. X.SH COMPATIBILITY
  2423. This is experimental software.  It is not compatible with any other
  2424. network protocols.  Not even other multicast protocols.  The fact that
  2425. we were able to fit the interface into the Berkeley networking socket
  2426. paradigm is a tribute to equal parts of stubbornness and the surprising
  2427. flexibility of that paradigm.  However, this software, including its
  2428. interface specification may change at any time.
  2429. X.PP
  2430. Since the software is
  2431. X.I not
  2432. part of the stock system software, some effort will probably be necessary
  2433. to use it.  Typically this will entail compiling your source with flags
  2434. something like
  2435. X.RI -I/ usr / local / include
  2436. and linking your program with flags
  2437. X.RI -L/ usr / local / lib
  2438. and
  2439. X.RI -l mcast .
  2440. Installations will differ from machine to machine and some installations
  2441. may not require anything special to access the multicast software.
  2442. X.PP
  2443. The current version of the multicast transport is implemented via a server,
  2444. X.IR mcastd (8),
  2445. which simulates multicast communication for its clients.  This fact
  2446. shouldn't affect most applications since it's completely hidden by the
  2447. application programming interface (API) presented in this and other
  2448. manual pages.  The hope is to replace this transport implementation with
  2449. a true network based multicast implementation in the future.  In the mean
  2450. time, this implementation allows people to work with the abstraction and
  2451. change it to experiment with it and its interface.  See
  2452. X.IR mcastd (8)
  2453. for more details about this implementation.
  2454. X.PP
  2455. One area where the current server implementation will affect applications
  2456. is in how the API software determines how to get to the server:
  2457. X.TP 5
  2458. To locate the server host:
  2459. If the environment variable MCASTD_SERVER is defined, it will be used as the
  2460. name of the host
  2461. X.I mcastd
  2462. is running on.  Otherwise, the host name
  2463. X.IR mcastd - server
  2464. will be used.  If the chosen host name is not found by
  2465. X.IR gethostbyname (3),
  2466. the address for the local host (via its loopback address) will be used.
  2467. X.TP 5
  2468. To determine the service port:
  2469. If the environment variable MCASTD_PORT is defined, it will be used as the
  2470. port number to use to contact
  2471. X.IR mcastd .
  2472. Otherwise, the service
  2473. X.IR mcast / tcp
  2474. will be looked up via
  2475. X.IR getservbyname (3).
  2476. XFinally, if that doesn't work, an installation configuration defined
  2477. constant will be used.  In the software distribution this is defined to be
  2478. X.IR 8001 .
  2479. X.SH PORTABILITY
  2480. Where possible, this software has been written to conform to ANSI C as
  2481. defined in
  2482. X.I "ANSI X3.159-1989"
  2483. and
  2484. POSIX 1003.1 as defined in
  2485. X.IR "IEEE Std 1003.1-1990" .
  2486. Unfortunately there are no standards available yet for networking APIs.
  2487. Where we were forced to step beyond the ANSI C and POSIX 1003.1 standards,
  2488. we chose to use the BSD
  2489. X.RI ( "Berkeley Software Distribution" )
  2490. definitions.  As such, it depends on the BSD
  2491. X.I socket
  2492. facilities, I/O control mechanisms, etc.
  2493. X.SH "SEE ALSO"
  2494. X.IR mc_bind (2),
  2495. X.IR mc_close (2),
  2496. X.IR mc_connect (2),
  2497. X.IR mc_fcntl (2),
  2498. X.IR mc_getpeername (2),
  2499. X.IR mc_getsockname (2),
  2500. X.IR mc_getsockopt (2),
  2501. X.IR mc_ioctl (2),
  2502. X.IR mc_read (2),
  2503. X.IR mc_recv (2),
  2504. X.IR mc_send (2),
  2505. X.IR mc_shutdown (2),
  2506. X.IR mc_socket (2),
  2507. X.IR mc_write (2),
  2508. X.IR mcast_getgroupbyname (3),
  2509. X.IR mcast_newaddr (3),
  2510. X.IR mcast_sopen (3),
  2511. X.IR mcastd (8m),
  2512. X.IR socket (2)
  2513. X.SH STANDARDS
  2514. There are no current standards that address multicast communication.
  2515. The software described in this manual page is experimental and subject
  2516. to change at any time.
  2517. END_OF_FILE
  2518. if test 13604 -ne `wc -c <'man/mcast.4'`; then
  2519.     echo shar: \"'man/mcast.4'\" unpacked with wrong size!
  2520. fi
  2521. # end of 'man/mcast.4'
  2522. fi
  2523. if test -f 'man/mcast_newaddr.3' -a "${1}" != "-c" ; then 
  2524.   echo shar: Will not clobber existing file \"'man/mcast_newaddr.3'\"
  2525. else
  2526. echo shar: Extracting \"'man/mcast_newaddr.3'\" \(5275 characters\)
  2527. sed "s/^X//" >'man/mcast_newaddr.3' <<'END_OF_FILE'
  2528. X.\" Copyright (c) 1992 The Regents of the University of California.
  2529. X.\" All rights reserved.
  2530. X.\"
  2531. X.\" Redistribution and use in source and binary forms, with or without
  2532. X.\" modification, are permitted provided that the following conditions
  2533. X.\" are met:
  2534. X.\" 1. Redistributions of source code must retain the above copyright
  2535. X.\"    notice, this list of conditions and the following disclaimer.
  2536. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2537. X.\"    notice, this list of conditions and the following disclaimer in the
  2538. X.\"    documentation and/or other materials provided with the distribution.
  2539. X.\" 3. All advertising materials mentioning features or use of this software
  2540. X.\"    must display the following acknowledgement:
  2541. X.\"    This product includes software developed by the University of
  2542. X.\"    California, Lawrence Livermore National Laboratory and its
  2543. X.\"    contributors.
  2544. X.\" 4. Neither the name of the University nor the names of its contributors
  2545. X.\"    may be used to endorse or promote products derived from this software
  2546. X.\"    without specific prior written permission.
  2547. X.\"
  2548. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2549. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2550. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2551. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2552. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2553. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2554. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2555. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2556. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2557. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2558. X.\" SUCH DAMAGE.
  2559. X.\"
  2560. X.de Hd
  2561. X.ds Dt \\$4
  2562. X..
  2563. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mcast_newaddr.3,v 1.1 92/10/16 18:23:08 casey Exp $
  2564. X.TH MCAST_NEWADDR 3 \*(Dt
  2565. X.SH NAME
  2566. mcast_newaddr \- create a new, globally unique multicast address
  2567. X.SH SYNOPSIS
  2568. X.nf
  2569. X.ft B
  2570. X#include <sys/types.h>
  2571. X#include <sys/socket.h>
  2572. X#include <netmcast/mcast.h>
  2573. X
  2574. int
  2575. mcast_newaddr(struct mc_addr *addr)
  2576. X.ft P
  2577. X.fi
  2578. X.SH DESCRIPTION
  2579. X.I Mcast_newaddr
  2580. creates a new multicast address and leaves it in
  2581. X.IR addr .
  2582. The address is guaranteed to be unique across all processes on all
  2583. hosts on all nets.  These addresses may be used for both new multicast
  2584. group identifiers and multicast group member addresses.  Further, once
  2585. a multicast address is created, it is completely opaque and is not
  2586. associated with the creating process, host, or network in any way.
  2587. Thus, a process is free to migrate to another host and continue to use
  2588. the same address.
  2589. X.PP
  2590. The address is created in a totally distributed manner; new name
  2591. generation does not depend on any complex, time consuming negotiation
  2592. with other hosts.  Thus, the speed of name generation is generally
  2593. limited only by the speed of the host.  (Well, almost, see below.)
  2594. X.PP
  2595. The current address generation algorithm incorporates host/process
  2596. identification, host clock, and an intra-clock-tick sequence number
  2597. to implement the distributed uniqueness property.  Note again that
  2598. once an address has been created, it is completely opaque.
  2599. X.PP
  2600. Addresses which are created close in time to each other may not be
  2601. distinguished via the creating host's clock.  For that reason, an
  2602. intra-clock-tick sequence number is used to further distinguish
  2603. addresses.  Since that sequence number is finite in the current
  2604. implementation, there is a finite rate at which address can be
  2605. generated.  That limit is currently approximately four billion per
  2606. second.  We refuse to humiliate ourselves by making some prediction as
  2607. to how long that rate should be sufficient.  The rate of progress in
  2608. the industry usually makes all such predictions ludicrous within a few
  2609. weeks of their utterance ...
  2610. X.SH COMPATIBILITY
  2611. X.I Mcast_newaddr
  2612. is unique to the experimental multicast implementation.  Given the
  2613. need for generating distributed, unique identifiers in the distributed
  2614. computing community, it shouldn't even be associated with multicast.
  2615. However, since we wanted to get on with our work and since the
  2616. identifiers directly corresponded to our multicast addresses, we
  2617. decided not to lose time working on a more general scheme.  In any
  2618. case, it would be easy enough to do that at a later time and replace
  2619. the definitions of
  2620. X.I mc_addr
  2621. and
  2622. X.I mcast_newaddr
  2623. with references to a general distributed identifier and identifier
  2624. creation routine.
  2625. X.SH "RETURN VALUES"
  2626. Upon successful completion, a value of 0 is returned and a new address is
  2627. left in
  2628. X.IR addr .
  2629. Otherwise, a value of -1 is returned and the global integer variable
  2630. X.I errno
  2631. is set to indicate the error.
  2632. X.SH ERRORS
  2633. X.TP 20
  2634. X[EAGAIN]
  2635. Unable to create a new multicast address at the current time.  An attempt
  2636. at a later time may be successful.
  2637. X.TP 20
  2638. X[EFAULT]
  2639. X.I Addr
  2640. is not in the user's memory map or is misaligned.
  2641. X.SH "SEE ALSO"
  2642. X.IR mcast (4),
  2643. X.IR mcast_getgroupbyname (3),
  2644. X.IR mc_socket (2)
  2645. X.SH STANDARDS
  2646. There are no current standards that address multicast communication.
  2647. The software described in this manual page is experimental and subject
  2648. to change at any time.
  2649. END_OF_FILE
  2650. if test 5275 -ne `wc -c <'man/mcast_newaddr.3'`; then
  2651.     echo shar: \"'man/mcast_newaddr.3'\" unpacked with wrong size!
  2652. fi
  2653. # end of 'man/mcast_newaddr.3'
  2654. fi
  2655. if test -f 'man/mcast_sopen.3' -a "${1}" != "-c" ; then 
  2656.   echo shar: Will not clobber existing file \"'man/mcast_sopen.3'\"
  2657. else
  2658. echo shar: Extracting \"'man/mcast_sopen.3'\" \(5587 characters\)
  2659. sed "s/^X//" >'man/mcast_sopen.3' <<'END_OF_FILE'
  2660. X.\" Copyright (c) 1992 The Regents of the University of California.
  2661. X.\" All rights reserved.
  2662. X.\"
  2663. X.\" Redistribution and use in source and binary forms, with or without
  2664. X.\" modification, are permitted provided that the following conditions
  2665. X.\" are met:
  2666. X.\" 1. Redistributions of source code must retain the above copyright
  2667. X.\"    notice, this list of conditions and the following disclaimer.
  2668. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2669. X.\"    notice, this list of conditions and the following disclaimer in the
  2670. X.\"    documentation and/or other materials provided with the distribution.
  2671. X.\" 3. All advertising materials mentioning features or use of this software
  2672. X.\"    must display the following acknowledgement:
  2673. X.\"    This product includes software developed by the University of
  2674. X.\"    California, Lawrence Livermore National Laboratory and its
  2675. X.\"    contributors.
  2676. X.\" 4. Neither the name of the University nor the names of its contributors
  2677. X.\"    may be used to endorse or promote products derived from this software
  2678. X.\"    without specific prior written permission.
  2679. X.\"
  2680. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2681. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2682. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2683. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2684. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2685. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2686. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2687. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2688. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2689. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2690. X.\" SUCH DAMAGE.
  2691. X.\"
  2692. X.de Hd
  2693. X.ds Dt \\$4
  2694. X..
  2695. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mcast_sopen.3,v 1.3 93/01/16 20:08:24 casey Exp $
  2696. X.TH MCAST_SOPEN 3 \*(Dt
  2697. X.SH NAME
  2698. mcast_sopen \- open a connection to a multicast group
  2699. X.SH SYNOPSIS
  2700. X.nf
  2701. X.ft B
  2702. X#include <fcntl.h>
  2703. X#include <sys/types.h>
  2704. X#include <sys/socket.h>
  2705. X#include <netmcast/mcast.h>
  2706. X
  2707. int
  2708. mcast_sopen(const char *group, int domain, int type, int mode)
  2709. X.ft P
  2710. X.fi
  2711. X.SH DESCRIPTION
  2712. X.I Mcast_sopen
  2713. creates a multicast socket in the
  2714. X.I domain
  2715. multicast protocol family of
  2716. X.IR type ,
  2717. sets various features based on
  2718. X.IR mode ,
  2719. and connects the socket to the multicast group specified by
  2720. X.IR group .
  2721. The initialized socket is returned.
  2722. This is basically a helper routine to hide a lot of the ugliness
  2723. associated with getting a multicast socket set up for use.
  2724. X.I Mcast_sopen
  2725. is meant to generally emulate the spirit of the
  2726. X.IR open (2)
  2727. call but for multicast groups instead of files.
  2728. X.PP
  2729. X.I Domain
  2730. is one of PF_MCAST or PF_AMCAST.
  2731. X.I Type
  2732. is one of SOCK_DGRAM, SOCK_RDM, SOCK_SEQPACKET, or SOCK_STREAM.
  2733. XFor PF_AMCAST, only SOCK_SEQPACKET and SOCK_STREAM are supported.
  2734. See
  2735. X.IR mc_socket (2)
  2736. for information regarding multicast socket creation and types.  See
  2737. X.IR mcast (4)
  2738. for information on multicast protocol operation and presentation
  2739. semantics.
  2740. X.PP
  2741. X.I Mode
  2742. should contain one of O_RDWR, O_RDONLY, or O_WRONLY
  2743. X.IR or 'ed
  2744. with any legal
  2745. X.IR mc_fcntl (2)
  2746. XF_SETFL flag set.  If O_RDONLY is specified, an
  2747. X.I mc_shutdown
  2748. with
  2749. X.IR how =1
  2750. will be performed on the socket.  Similarly, if O_WRONLY is specified, an
  2751. X.I mc_shutdown
  2752. with
  2753. X.IR how =2
  2754. will be performed on the socket.
  2755. The remaining mode bits will be passed to
  2756. X.IR mc_fcntl (2).
  2757. X.PP
  2758. Note that this gives a completely different semantic for O_NONBLOCK from
  2759. X.IR open (2).
  2760. XFor
  2761. X.IR open ,
  2762. O_NONBLOCK specifies that the
  2763. X.I open
  2764. shouldn't block if the file being opened corresponds to a device \(em
  2765. such as a tty \(em that can block during an open operation.  Further,
  2766. using O_NONBLOCK in an
  2767. X.I open
  2768. call does
  2769. X.I not
  2770. cause the returned file descriptor to be put in non-blocking I/O
  2771. mode (as via usage of O_NONBLOCK with
  2772. X.IR fcntl ).
  2773. X.PP
  2774. XFor
  2775. X.I mcast_sopen
  2776. on the other hand, using O_NONBLOCK
  2777. X.I does
  2778. cause the file descriptor to be put into non-blocking I/O mode since
  2779. the non-access control mode bits are passed to
  2780. X.IR mc_fcntl .
  2781. X.SH COMPATIBILITY
  2782. X.I Mcast_sopen
  2783. is unique to the experimental multicast implementation.  It's actually
  2784. amazingly convenient.  Someone should do something similar for the
  2785. other network protocol families.  Eg:
  2786. X.IR inet_sopen (...).
  2787. X.SH "RETURN VALUES"
  2788. A -1 is returned if an error occurs, otherwise the return
  2789. value is a descriptor referencing the multicast socket connected
  2790. to the specified group.
  2791. X.SH ERRORS
  2792. X.TP 20
  2793. X[EPROTONOSUPPORT]
  2794. X.I Type
  2795. is not one of SOCK_DGRAM, SOCK_RDM, SOCK_SEQPACKET, or SOCK_STREAM.
  2796. X.TP 20
  2797. X[EINVAL]
  2798. X.I Mode
  2799. contained an illegal value.
  2800. X.TP 20
  2801. X[EMFILE]
  2802. The fixed size multicast socket state space was exceeded.  So shoot me
  2803. for putting in a fixed limit.  This is just an experimental package to
  2804. demonstrate proof of concept ...
  2805. X.TP 20
  2806. X[EHOSTUNREACH]
  2807. The address couldn't be determined of the machine running the
  2808. multicast communication server.  This is an artifact of a
  2809. client/server implementation of the multicast communication system.
  2810. X.TP 20
  2811. X[ENOENT]
  2812. X.I Mcast_getgroupbyname
  2813. was unable to find any information on
  2814. X.IR group .
  2815. X.TP 20
  2816. X[ENOMEM]
  2817. X.I Mcast_getgroupbyname
  2818. was unable to
  2819. X.I malloc
  2820. storage.
  2821. X.SH "SEE ALSO"
  2822. X.IR mcast (4),
  2823. X.IR mcast_getgroupbyname (3),
  2824. X.IR mc_fcntl (2),
  2825. X.IR mc_socket (2)
  2826. X.SH STANDARDS
  2827. There are no current standards that address multicast communication.
  2828. The software described in this manual page is experimental and subject
  2829. to change at any time.
  2830. END_OF_FILE
  2831. if test 5587 -ne `wc -c <'man/mcast_sopen.3'`; then
  2832.     echo shar: \"'man/mcast_sopen.3'\" unpacked with wrong size!
  2833. fi
  2834. # end of 'man/mcast_sopen.3'
  2835. fi
  2836. if test -f 'man/mcastd.8' -a "${1}" != "-c" ; then 
  2837.   echo shar: Will not clobber existing file \"'man/mcastd.8'\"
  2838. else
  2839. echo shar: Extracting \"'man/mcastd.8'\" \(5500 characters\)
  2840. sed "s/^X//" >'man/mcastd.8' <<'END_OF_FILE'
  2841. X.\" Copyright (c) 1992 The Regents of the University of California.
  2842. X.\" All rights reserved.
  2843. X.\"
  2844. X.\" Redistribution and use in source and binary forms, with or without
  2845. X.\" modification, are permitted provided that the following conditions
  2846. X.\" are met:
  2847. X.\" 1. Redistributions of source code must retain the above copyright
  2848. X.\"    notice, this list of conditions and the following disclaimer.
  2849. X.\" 2. Redistributions in binary form must reproduce the above copyright
  2850. X.\"    notice, this list of conditions and the following disclaimer in the
  2851. X.\"    documentation and/or other materials provided with the distribution.
  2852. X.\" 3. All advertising materials mentioning features or use of this software
  2853. X.\"    must display the following acknowledgement:
  2854. X.\"    This product includes software developed by the University of
  2855. X.\"    California, Lawrence Livermore National Laboratory and its
  2856. X.\"    contributors.
  2857. X.\" 4. Neither the name of the University nor the names of its contributors
  2858. X.\"    may be used to endorse or promote products derived from this software
  2859. X.\"    without specific prior written permission.
  2860. X.\"
  2861. X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  2862. X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  2863. X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  2864. X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  2865. X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  2866. X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  2867. X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  2868. X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  2869. X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  2870. X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  2871. X.\" SUCH DAMAGE.
  2872. X.\"
  2873. X.de Hd
  2874. X.ds Dt \\$4
  2875. X..
  2876. X.Hd $Header: /u0/casey/src/mcast/man/RCS/mcastd.8,v 1.1 92/10/16 18:23:09 casey Exp $
  2877. X.TH MCASTD 8 \*(Dt
  2878. X.SH NAME
  2879. mcastd \- multicast protocol server
  2880. X.SH SYNOPSIS
  2881. X.nf
  2882. X.ft B
  2883. mcastd [-d] [-l log-level] [-p port]
  2884. X.ft P
  2885. X.fi
  2886. X.SH DESCRIPTION
  2887. X.I Mcastd
  2888. is a server which simulates multicast communication for its clients.
  2889. Clients connect to
  2890. X.IR mcastd ,
  2891. subscribe to a
  2892. X.IR "multicast group" ,
  2893. and then send and receive messages on that group.
  2894. X.I Mcastd
  2895. is a precursor to an implementation of multicast communication that uses
  2896. real network multicast facilities.
  2897. X.PP
  2898. The following command line options are supported by
  2899. X.IR mcastd :
  2900. X.TP 5
  2901. X\fB\-d\fP
  2902. XEnables debug mode.
  2903. X.I Mcastd
  2904. will not disconnect from the tty.  All log messages will be sent to the
  2905. tty instead of the system logger.
  2906. X.TP 5
  2907. X\fB\-l\fP \fIlog\fP-\fIlevel\fP
  2908. Sets the system log level filter.  Only log messages at this or lower
  2909. levels will be logged.  The default log level is LOG_NOTICE (5 in most
  2910. systems).  This will cause messages noting normal, but significant
  2911. conditions to be logged.  Log level LOG_DEBUG (7 on most systems) will
  2912. cause copious amounts of messages to be logged detailing intimacies of
  2913. X.IR mcastd 's
  2914. operations.  LOG_DEBUG should only be used when debugging
  2915. X.I mcastd
  2916. since using it on a long term basis may well fill up a system's log
  2917. disk.
  2918. X.TP 5
  2919. X\fB\-p\fP \fIport\fP
  2920. Tells
  2921. X.I mcastd
  2922. to set up shop on the indicated
  2923. X.I port
  2924. instead of the default port.  (The default port is defined at installation
  2925. configuration.  In the software distribution it is defined to be
  2926. X.IR 8001 .
  2927. X.PP
  2928. A running
  2929. X.I mcastd
  2930. also responds to the following signals:
  2931. X.TP 5
  2932. SIGHUP
  2933. Causes
  2934. X.I mcastd
  2935. to reset.  All current connections are dropped and the server restarts.
  2936. X.TP 5
  2937. SIGTERM
  2938. Causes
  2939. X.I mcastd
  2940. to shutdown.  All current connections are dropped and the server exits.
  2941. X.PP
  2942. In operation, clients connect to
  2943. X.I mcastd
  2944. as they would any TCP based server.  Once connected they may send either
  2945. server control messages or data messages and receive data messages from
  2946. other clients (and sometimes themselves).  Service is terminated by either
  2947. the client or the server closing the connection.  The server should only
  2948. ever close its end of the connection if an error occurs or it is told to
  2949. reset or shutdown.
  2950. X.PP
  2951. The server control message format is described in
  2952. X.RI < netmcast / mcastd . h >
  2953. and the data message format is described in
  2954. X.RI < netmcast / mcast . h >.
  2955. However, under normal circumstances, no one should ever have to talk
  2956. directly to the server since there is a complete Berkeley socket-style
  2957. programming interface available.
  2958. X.SH COMPATIBILITY
  2959. This is experimental software.  It is not compatible with any other
  2960. multicast software.
  2961. X.SH PORTABILITY
  2962. Where possible, this software has been written to conform to ANSI C as
  2963. defined in
  2964. X.I "ANSI X3.159-1989"
  2965. and
  2966. POSIX 1003.1 as defined in
  2967. Unfortunately there are no standards available yet for networking APIs.
  2968. Where we were forced to step beyond the ANSI C and POSIX 1003.1 standards,
  2969. we chose to use the BSD
  2970. X.RI ( "Berkeley Software Distribution" )
  2971. definitions.  As such, it depends on the BSD
  2972. X.I socket
  2973. facilities, I/O control mechanisms, etc.
  2974. X.I Mcastd
  2975. also depends on
  2976. X.IR select (2)
  2977. to handle multiplexing multiple client connections.
  2978. X.IR "IEEE Std 1003.1-1990" .
  2979. X.SH "RETURN VALUES"
  2980. X.SH ERRORS
  2981. X.SH "SEE ALSO"
  2982. X.IR mcast (4),
  2983. X.IR mc_socket (2),
  2984. X.IR select (2),
  2985. X.IR socket (2),
  2986. X.IR syslog (3),
  2987. X.IR syslogd (8)
  2988. X.SH STANDARDS
  2989. There are no current standards that address multicast communication.
  2990. The software described in this manual page is experimental and subject
  2991. to change at any time.
  2992. END_OF_FILE
  2993. if test 5500 -ne `wc -c <'man/mcastd.8'`; then
  2994.     echo shar: \"'man/mcastd.8'\" unpacked with wrong size!
  2995. fi
  2996. # end of 'man/mcastd.8'
  2997. fi
  2998. if test -f 'test/mc_ping.c' -a "${1}" != "-c" ; then 
  2999.   echo shar: Will not clobber existing file \"'test/mc_ping.c'\"
  3000. else
  3001. echo shar: Extracting \"'test/mc_ping.c'\" \(5914 characters\)
  3002. sed "s/^X//" >'test/mc_ping.c' <<'END_OF_FILE'
  3003. X/*
  3004. X * $Header: /u0/casey/src/mcast/test/RCS/mc_ping.c,v 1.4 93/01/16 20:18:39 casey Exp $
  3005. X */
  3006. X
  3007. X/*
  3008. X * Copyright (c) 1992 The Regents of the University of California.
  3009. X * All rights reserved.
  3010. X *
  3011. X * Redistribution and use in source and binary forms, with or without
  3012. X * modification, are permitted provided that the following conditions
  3013. X * are met:
  3014. X * 1. Redistributions of source code must retain the above copyright
  3015. X *    notice, this list of conditions and the following disclaimer.
  3016. X * 2. Redistributions in binary form must reproduce the above copyright
  3017. X *    notice, this list of conditions and the following disclaimer in the
  3018. X *    documentation and/or other materials provided with the distribution.
  3019. X * 3. All advertising materials mentioning features or use of this software
  3020. X *    must display the following acknowledgement:
  3021. X *    This product includes software developed by the University of
  3022. X *    California, Lawrence Livermore National Laboratory and its
  3023. X *    contributors.
  3024. X * 4. Neither the name of the University nor the names of its contributors
  3025. X *    may be used to endorse or promote products derived from this software
  3026. X *    without specific prior written permission.
  3027. X *
  3028. X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  3029. X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  3030. X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  3031. X * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  3032. X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  3033. X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  3034. X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  3035. X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  3036. X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  3037. X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  3038. X * SUCH DAMAGE.
  3039. X */
  3040. X
  3041. X#ifndef lint
  3042. static char rcsid[] = "$Header: /u0/casey/src/mcast/test/RCS/mc_ping.c,v 1.4 93/01/16 20:18:39 casey Exp $";
  3043. static char copyright[] =
  3044. X    "Copyright (c) 1992 The Regents of the University of California.\n"
  3045. X    "All rights reserved.\n";
  3046. static char classification[] =
  3047. X    "Unclassified\n";
  3048. X#endif
  3049. X
  3050. X/*
  3051. X * Send messages to ourself on a specified multicast group and measure and
  3052. X * print the round trip time.
  3053. X */
  3054. X
  3055. X
  3056. X#include <errno.h>
  3057. X#include <fcntl.h>
  3058. X#include <stddef.h>
  3059. X#include <stdio.h>
  3060. X#include <stdlib.h>
  3061. X#include <string.h>
  3062. X#include <unistd.h>
  3063. X#include <sys/types.h>
  3064. X
  3065. X#include <sys/time.h>
  3066. X#include <sys/socket.h>
  3067. X#include <netmcast/mcast.h>
  3068. X
  3069. X
  3070. X/*
  3071. X * Arguments.
  3072. X */
  3073. char    *myname;            /* name we were invoked by */
  3074. int    header = 0;            /* print a header for every message */
  3075. int    debug = 0;            /* print lots of debug information */
  3076. int    size = 1024;            /* size of packets to ping with */
  3077. char    *group;                /* multicast group to listen to */
  3078. X
  3079. X
  3080. X/*
  3081. X * Local types.
  3082. X */
  3083. typedef struct mtag {
  3084. X    struct timeval    time;        /* time message was sent out */
  3085. X    unsigned long    seq;        /* sequence number of message */
  3086. X} mtag;
  3087. X
  3088. X
  3089. X/*
  3090. X * Local routines.
  3091. X */
  3092. void usage(void);            /* issue usage and exit with error */
  3093. void ping(void);            /* the ping routine */
  3094. X
  3095. X
  3096. main(int argc, char *argv[])
  3097. X{
  3098. X    int opt;
  3099. X    extern int getopt(int, char **, char *);
  3100. X    extern char *optarg;
  3101. X    extern int optind;
  3102. X
  3103. X    /*
  3104. X     * Parse any arguments ...
  3105. X     */
  3106. X    myname = argv[0];
  3107. X    while ((opt = getopt(argc, argv, "dhs:")) != EOF)
  3108. X        switch ((char)opt) {
  3109. X            case '?':
  3110. X            usage();
  3111. X            /*NOTREACHED*/
  3112. X            case 'd':
  3113. X            debug = 1;
  3114. X            break;
  3115. X            case 'h':
  3116. X            header = 1;
  3117. X            break;
  3118. X            case 's':
  3119. X            size = atoi(optarg);
  3120. X            break;
  3121. X        }
  3122. X    if (argc != optind+1) {
  3123. X        usage();
  3124. X        /*NOTREACHED*/
  3125. X    }
  3126. X    group = argv[optind];
  3127. X    if (size < sizeof(mtag)) {
  3128. X        fprintf(stderr, "%s: message size must be at least %u\n",
  3129. X            myname, sizeof(mtag));
  3130. X        size = sizeof(mtag);
  3131. X    }
  3132. X    ping();
  3133. X    exit(0);
  3134. X    /*NOTREACHED*/
  3135. X}
  3136. X
  3137. X
  3138. static void
  3139. ping(void)
  3140. X{
  3141. X    int s, n;
  3142. X    char *buf;
  3143. X    unsigned long seq;
  3144. X    fd_set readfds;
  3145. X    struct sockaddr_mcast addr;
  3146. X    struct timeval timeout;
  3147. X#ifndef _AIX
  3148. X    /*
  3149. X     * Patch around problem in IBM's AIX 3.2 where they define select
  3150. X     * with void pointers in <sys/select.h>.
  3151. X     */
  3152. X    extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
  3153. X#endif
  3154. X
  3155. X    buf = malloc((size_t)size);
  3156. X    if (buf == NULL) {
  3157. X        fprintf(stderr, "%s: unable to allocate %d size ping buffer!\n",
  3158. X            myname, size);
  3159. X        return;
  3160. X    }
  3161. X    (void)memset(buf, 0, size);
  3162. X    s = mcast_sopen(group, PF_MCAST, SOCK_STREAM, O_RDWR|MCO_LOOPBACK);
  3163. X    if (s < 0) {
  3164. X        perror("mcast_sopen");
  3165. X        exit(1);
  3166. X    }
  3167. X    n = sizeof(addr);
  3168. X    if (mc_getsockname(s, (struct sockaddr *)&addr, &n) < 0) {
  3169. X        perror("mc_getsockname");
  3170. X        exit(1);
  3171. X    }
  3172. X    seq = 0;
  3173. X    FD_ZERO(&readfds);
  3174. X    FD_SET(s, &readfds);
  3175. X    timeout.tv_sec = 1;
  3176. X    timeout.tv_usec = 0;
  3177. X    for (;;) {
  3178. X        int cc;
  3179. X
  3180. X        ((mtag *)buf)->seq = seq;
  3181. X        seq++;
  3182. X        (void)gettimeofday(&((mtag *)buf)->time, NULL);
  3183. X        cc = mc_sendto(s, buf, size, 0,
  3184. X                   (struct sockaddr *)&addr, sizeof(addr));
  3185. X        if (cc < 0) {
  3186. X            perror("write");
  3187. X            return;
  3188. X        }
  3189. X        if (cc < size) {
  3190. X            fprintf(stderr, "%s: write only wrote %d of %d!\n",
  3191. X                myname, cc, size);
  3192. X            return;
  3193. X        }
  3194. X        for (;;) {
  3195. X            int nfds;
  3196. X            fd_set fds;
  3197. X            struct timeval tN;
  3198. X            long delta;
  3199. X
  3200. X            fds = readfds;
  3201. X            nfds = select(s+1, &fds, NULL, NULL, &timeout);
  3202. X            if (nfds == 0)
  3203. X                break;
  3204. X            cc = mc_read(s, buf, size);
  3205. X            (void)gettimeofday(&tN, NULL);
  3206. X            if (cc == 0)
  3207. X                break;
  3208. X            if (cc < 0) {
  3209. X                perror("read");
  3210. X                return;
  3211. X            }
  3212. X            if (cc < size) {
  3213. X                fprintf(stderr, "%s: read only read %d of %d!\n",
  3214. X                    myname, cc, size);
  3215. X                return;
  3216. X            }
  3217. X            delta = (tN.tv_sec - ((mtag *)buf)->time.tv_sec) * 1000000
  3218. X                  + tN.tv_usec - ((mtag *)buf)->time.tv_usec;
  3219. X            printf("seq=%ld time=%ld us\n", ((mtag *)buf)->seq, delta);
  3220. X        }
  3221. X    }
  3222. X    /*NOTREACHED*/
  3223. X}
  3224. X
  3225. X
  3226. void
  3227. usage()
  3228. X    /*
  3229. X     * Issue usage message and exit with an error.
  3230. X     */
  3231. X{
  3232. X    fprintf(stderr, "usage: %s [-h] [-d] [-s size] group\n", myname);
  3233. X    exit(1);
  3234. X}
  3235. END_OF_FILE
  3236. if test 5914 -ne `wc -c <'test/mc_ping.c'`; then
  3237.     echo shar: \"'test/mc_ping.c'\" unpacked with wrong size!
  3238. fi
  3239. # end of 'test/mc_ping.c'
  3240. fi
  3241. echo shar: End of archive 3 \(of 4\).
  3242. cp /dev/null ark3isdone
  3243. MISSING=""
  3244. for I in 1 2 3 4 ; do
  3245.     if test ! -f ark${I}isdone ; then
  3246.     MISSING="${MISSING} ${I}"
  3247.     fi
  3248. done
  3249. if test "${MISSING}" = "" ; then
  3250.     echo You have unpacked all 4 archives.
  3251.     rm -f ark[1-9]isdone
  3252. else
  3253.     echo You still need to unpack the following archives:
  3254.     echo "        " ${MISSING}
  3255. fi
  3256. ##  End of shell archive.
  3257. exit 0
  3258.