00001 #include "connect.h"
00002 #include <stdlib.h>
00006 #define BUFFERSIZE 512
00007 int main(int argc, char *argv[]) {
00008 if (argc < 3) {
00009 printf("%s host port\n",argv[0]);
00010 return 1;
00011 }
00012 struct hostent *he = gethostbyname(argv[1]);
00013 if (he == NULL) {
00014 printf("Could not resolve host %s!\n",argv[1]);
00015 return 0;
00016 }
00017 int port = atoi(argv[2]);
00018 int in = connect(he,port);
00019 if (in <= 0) {
00020 printf("Could not connect to host %s:%d!\n",argv[1],port);
00021 }
00022 int out = STDOUT_FILENO;
00023 char buffer[BUFFERSIZE];
00024 while (-1!=read(in,buffer,BUFFERSIZE)) {
00025 write(out,buffer,BUFFERSIZE);
00026 }
00027 return 0;
00028 }