From: <kev...@us...> - 2002-11-01 05:53:26
|
Update of /cvsroot/bidwatcher/bidwatcher-1.4/src In directory usw-pr-cvs1:/tmp/cvs-serv1808 Modified Files: .cvsignore Added Files: testclient.c Log Message: add my testclient for biddaemon. --- NEW FILE: testclient.c --- #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <netinet/in.h> #include <netdb.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include "daemon.h" int main (int argc, char *argv[]) { int sock = 0, ret = 0; char *ip = argv[1]; char *port = argv[2]; char inbuf[1024]; struct bidmessage bm; struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(atoi(port)); sin.sin_addr.s_addr = inet_addr(ip); memset(inbuf, 0, sizeof inbuf); sock = socket(AF_INET, SOCK_STREAM, 0); ret = connect(sock, (struct sockaddr *)&sin, sizeof sin); if (ret == -1) { perror("connect()"); exit(0); } memset(&bm, 0, sizeof (bm)); // bm.type = 1; ret = write(sock, &bm, sizeof bm); if (ret == -1) { perror("write()"); exit(0); } ret = read(sock, inbuf, sizeof inbuf); if (ret == -1) { perror("read()"); exit(0); } printf("Response: %s\n", inbuf); // bm.type = 0; ret = write(sock, &bm, sizeof (bm)); sleep(4); close(sock); return 0; } /* * Local variables: * c-basic-offset: 8 * c-indent-level: 8 * tab-width: 8 * compile-command: "gcc -Wall -I ../include -o testclient testclient.c" * End: */ Index: .cvsignore =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher-1.4/src/.cvsignore,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- .cvsignore 29 Oct 2002 04:27:13 -0000 1.4 +++ .cvsignore 1 Nov 2002 05:53:23 -0000 1.5 @@ -1,5 +1,6 @@ bidwatcher biddaemon +testclient Makefile Makefile.in .deps |