#define TO_1	127
#define TO_2	0
#define TO_3	0
#define TO_4	1

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>

#define BUFLEN	512

/* init_socket sets up the mother descriptor - creates the socket, sets
 * its options up, binds it, and listens.  */
int	init_socket(void)
{
   int	s;

   /*
    * Should the first argument to socket() be AF_INET or PF_INET?  I don't
    * know.  Take your pick.  PF_INET seems to be more widely adopted, but
    * all implementations I've seen define AF_INET and PF_INET to be
    * synonymous anyway.
    */

   if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
      perror("Create socket");
      exit(1);
   }

   return(s);
}


int main()
{
   int s;
   struct sockaddr_in sa;
   char buf[BUFLEN];

   s = init_socket();

   sa.sin_family = AF_INET;
   sa.sin_port = htons(4991);
   sa.sin_addr.s_addr=htonl((TO_1 << 24) | (TO_2 << 16) | (TO_3 << 8) | TO_4);


   puts("Enter a one-line message.");
   gets(buf);
   sendto(s, buf, strlen(buf), 0, (struct sockaddr *)&sa, sizeof(sa));
   exit(0);
}

