38 int maxPendingConnections)
41 fd_ = socket(AF_UNIX, SOCK_STREAM, 0);
43 ERROR(
"Creating client socket");
44 throw std::runtime_error (
"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(),
52 sizeof(serv_addr.sun_path) - 1);
53 if (bind(
fd_, (
struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0) {
56 throw std::runtime_error (
"Bind error");
60 if (listen(
fd_, maxPendingConnections) < 0) {
63 throw std::runtime_error (
"Listen error");
80 fd_ = socket(AF_INET, SOCK_STREAM, 0);
82 ERROR(
"Creating client socket");
83 throw std::runtime_error (
"Socket error");
87 struct sockaddr_in serv_addr;
88 bzero((
char *) &serv_addr,
sizeof(serv_addr));
89 serv_addr.sin_family = AF_INET;
90 serv_addr.sin_port = htons(port);
91 serv_addr.sin_addr.s_addr = INADDR_ANY;
92 if (bind(
fd_, (
struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0) {
95 throw std::runtime_error (
"Bind error");
99 if (listen(
fd_, maxPendingConnections) < 0) {
102 throw std::runtime_error (
"Listen error");