1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
/*
* $Id: client.c,v 1.1 2002-10-14 10:31:36 cvs Exp $
*/
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <strings.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "gssTunnel.h"
int
main(int argc, char *argv[])
{
int fd;
struct sockaddr_in serv_addr;
struct hostent *hp;
char c;
if(argc != 3 ) {
printf("Usage: %s <host> <port>\n", argv[0]);
exit(1);
}
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
exit(1);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(atoi(argv[2]));
hp = (struct hostent *) gethostbyname(argv[1]);
if (hp == NULL) {
if ((serv_addr.sin_addr.s_addr = inet_addr(argv[1])) < 0) {
close(fd);
perror("gethostbyname");
exit(1);
}
} else {
bcopy(hp->h_addr_list[0], &serv_addr.sin_addr.s_addr, hp->h_length);
}
if (connect(fd, (struct sockaddr *) & serv_addr, sizeof(serv_addr)) < 0) {
close(fd);
perror("connect");
exit(1);
}
printf("Done %d %d\n", fd, eInit(fd));
while(1) {
eWrite(fd, "Hello Java\n", 11);
while(1) {
if ( eRead(fd, &c, 1) < 0 ) return 1;
putchar(c); fflush(stdout);
if(c=='\n') break;
}
}
close(fd);
return 0;
}
|