1 #define _POSIX_SOURCE 1
6 #include <sys/socket.h>
14 int main(int argc, char **argv) {
18 struct addrinfo hints;
19 struct addrinfo *address;
20 struct addrinfo *addr_ptr;
23 memset(buf, 0, BUF_SIZE);
24 memset(&hints, 0, sizeof(struct addrinfo));
25 hints.ai_family = AF_INET;
26 hints.ai_socktype = SOCK_STREAM;
29 rv = getaddrinfo("castor-pvt", "1210", &hints, &address);
31 fprintf(stderr, "Error looking up hostname, %d\n", errno);
36 for (addr_ptr = address; addr_ptr != NULL; addr_ptr = addr_ptr->ai_next) {
37 sock = socket(addr_ptr->ai_family,
38 addr_ptr->ai_socktype,
39 addr_ptr->ai_protocol);
44 rv = connect(sock, addr_ptr->ai_addr, addr_ptr->ai_addrlen);
50 if (addr_ptr == NULL) {
51 fprintf(stderr, "Could not connect\n");
55 freeaddrinfo(address);
57 nread = read(sock, buf, BUF_SIZE-1);
59 fprintf(stderr, "read error");
62 fprintf(stdout, "castor_load = %s", buf);
63 fprintf(stdout, "--\n");