home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / mcast / part01 / test / mc_hello.c < prev   
Encoding:
C/C++ Source or Header  |  1993-04-06  |  2.7 KB  |  74 lines

  1. /*
  2.  * $Header: /u0/casey/src/mcast/test/RCS/mc_hello.c,v 1.3 93/01/16 20:18:35 casey Exp $
  3.  */
  4.  
  5. /*
  6.  * Copyright (c) 1992 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  * 3. All advertising materials mentioning features or use of this software
  18.  *    must display the following acknowledgement:
  19.  *    This product includes software developed by the University of
  20.  *    California, Lawrence Livermore National Laboratory and its
  21.  *    contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  */
  38.  
  39. #ifndef lint
  40. static char rcsid[] = "$Header: /u0/casey/src/mcast/test/RCS/mc_hello.c,v 1.3 93/01/16 20:18:35 casey Exp $";
  41. static char copyright[] =
  42.     "Copyright (c) 1992 The Regents of the University of California.\n"
  43.     "All rights reserved.\n";
  44. static char classification[] =
  45.     "Unclassified\n";
  46. #endif
  47.  
  48. /*
  49.  * Emit "hello world!" onto the "hello-world-group" multicast group.
  50.  */
  51.  
  52.  
  53. #include <stdio.h>
  54. #include <fcntl.h>
  55. #include <sys/types.h>
  56. #include <sys/socket.h>
  57. #include <netmcast/mcast.h>
  58.  
  59. /*ARGSUSED*/
  60. main(int argc, char *argv[])
  61. {
  62.     int s;
  63.  
  64.     s = mcast_sopen("hello-world-group", PF_MCAST, SOCK_STREAM, O_WRONLY);
  65.     if (s < 0) {
  66.         perror("mcast_sopen");
  67.         exit(1);
  68.     }
  69.     (void)mc_write(s, "hello world!\n", 13);
  70.     (void)mc_close(s);
  71.     exit(0);
  72.     /*NOTREACHED*/
  73. }
  74.