#include <stdio.h>
#include <string.h>
#include <netfd.h>

#define	DEF_ADDR	"192.168.1.23"
#define	DEF_PORT	"31415"
#define	DEF_TIMEOUT	(5000)	/* milliseconds */

int
main(argc, argv)
	int	argc;
	char *	argv[];
{
  if (netfd_init(0) == 0) {
    NetFD	nfd;

    nfd = netfd_tcp_client(DEF_ADDR, DEF_PORT, DEF_TIMEOUT);
    if (nfd != NULL) {
      ssize_t	n;
      char	buf[256];

      memset(buf, 0, sizeof(buf));
      while ((n = netfd_read(nfd, buf, sizeof(buf), NETFD_NO_TIMEOUT)) > 0) {
	fprintf(stdout, "%s", buf);
	memset(buf, 0, sizeof(buf));
      }
      netfd_close(nfd);
    }
  }

  return 0;
}
