2 * Conky, a system monitor, based on torsmo
4 * This program is licensed under BSD license, read COPYING
11 okay, nothing here right now. thanks for coming out
22 #include <sys/types.h>
23 #include <netinet/in.h>
24 #include <sys/socket.h>
26 #define PORT 3490 // the port client will be connecting to
28 #define MAXDATASIZE 100 // max number of bytes we can get at once
33 char buf[MAXDATASIZE];
35 struct sockaddr_in their_addr; // connector's address information
36 if ((he=gethostbyname("localhost")) == NULL) { // get the host info
37 perror("gethostbyname");
41 if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
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
51 if (connect(sockfd, (struct sockaddr *)&their_addr,
52 sizeof(struct sockaddr)) == -1) {
57 if ((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
64 printf("Received: %s",buf);