$execibar and $execigraph were broken. thanks to GimmeFuel for the heads-up
[monky] / src / remotec.c
1 /*
2  * Conky, a system monitor, based on torsmo
3  *
4  * This program is licensed under BSD license, read COPYING
5  *
6  *  $Id$
7  */
8  
9  /*
10  
11  okay, nothing here right now.  thanks for coming out
12  
13  */
14
15 #include "conky.h"
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <errno.h>
20 #include <string.h>
21 #include <netdb.h>
22 #include <sys/types.h>
23 #include <netinet/in.h>
24 #include <sys/socket.h>
25
26 #define PORT 3490 // the port client will be connecting to 
27
28 #define MAXDATASIZE 100 // max number of bytes we can get at once 
29
30 void client()
31 {
32         int sockfd, numbytes;  
33         char buf[MAXDATASIZE];
34         struct hostent *he;
35         struct sockaddr_in their_addr; // connector's address information 
36         if ((he=gethostbyname("localhost")) == NULL) {  // get the host info 
37                 perror("gethostbyname");
38                 exit(1);
39         }
40
41         if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
42                 perror("socket");
43                 exit(1);
44         }
45
46         their_addr.sin_family = AF_INET;    // host byte order 
47         their_addr.sin_port = htons(PORT);  // short, network byte order 
48         their_addr.sin_addr = *((struct in_addr *)he->h_addr);
49         memset(&(their_addr.sin_zero), '\0', 8);  // zero the rest of the struct 
50
51         if (connect(sockfd, (struct sockaddr *)&their_addr,
52             sizeof(struct sockaddr)) == -1) {
53                     perror("connect");
54                     exit(1);
55             }
56
57             if ((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
58                     perror("recv");
59                     exit(1);
60             }
61
62             buf[numbytes] = '\0';
63
64             printf("Received: %s",buf);
65
66             close(sockfd);
67
68             return;
69 }