22 #include <sys/socket.h>
23 #include <netinet/in.h>
24 #include <arpa/inet.h>
41 fd_ = socket(AF_UNIX, SOCK_STREAM, 0);
43 ERROR(
"Creating client socket");
44 throw std::runtime_error (
"Client socket error");
48 struct sockaddr_un serv_addr;
49 bzero((
char *) &serv_addr,
sizeof(serv_addr));
50 serv_addr.sun_family = AF_UNIX;
51 strncpy(serv_addr.sun_path, name.c_str(),
sizeof(serv_addr.sun_path) - 1);
52 if (connect(
fd_, (
struct sockaddr *) &serv_addr,
53 sizeof(serv_addr)) < 0) {
56 throw std::runtime_error (
"Client socket error");
72 fd_ = socket(AF_INET, SOCK_STREAM, 0);
74 ERROR(
"Creating client socket");
75 throw std::runtime_error (
"Client socket error");
79 struct sockaddr_in serv_addr;
80 bzero((
char *) &serv_addr,
sizeof(serv_addr));
81 serv_addr.sin_family = AF_INET;
82 serv_addr.sin_port = htons(port);
85 inet_aton(address.c_str(), &addr);
86 bcopy(&addr, &serv_addr.sin_addr.s_addr,
sizeof(addr));
88 if (connect(
fd_, (
struct sockaddr *) &serv_addr,
89 sizeof(serv_addr)) < 0) {
92 throw std::runtime_error (
"Client socket error");