#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "uici.h"
int copyfile(int fromfd, int tofd);
 
int main(int argc, char *argv[])
{
   int bytes_copied;
   int communfd;
   u_port_t portnumber;
 
   if (argc != 3) {
      fprintf(stderr, "Usage: %s host port\n", argv[0]);
      return 1;
   }
   portnumber = (u_port_t)atoi(argv[2]);
   if ((communfd = u_connect(portnumber, argv[1])) < 0) {
      fprintf(stderr, "Connection failed: %s\n", u_strerror(communfd));
      return 1;
   }
   fprintf(stderr, "[%ld]: A connection has been made to %s\n",
                    (long)getpid(), argv[1]);
   bytes_copied = copyfile(STDIN_FILENO, communfd);
   close(communfd);
   fprintf(stderr, "[%ld]:Bytes sent = %d\n", (long) getpid(), bytes_copied);
   return 0;
}

