40 fd_ = socket(AF_UNIX, SOCK_DGRAM, 0);
42 ERROR(
"Socket creation");
43 throw std::runtime_error (
"Socket error");
47 struct sockaddr_un serv_addr;
48 bzero((
char *) &serv_addr,
sizeof(serv_addr));
49 serv_addr.sun_family = AF_UNIX;
50 strncpy(serv_addr.sun_path, name.c_str(),
51 sizeof(serv_addr.sun_path) - 1);
52 if (bind(
fd_, (
struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0) {
54 ERROR(
"Socket binding");
55 throw std::runtime_error (
"Bind error");
70 fd_ = socket(AF_INET, SOCK_DGRAM, 0);
72 ERROR(
"Socket creation");
73 throw std::runtime_error (
"Socket error");
77 struct sockaddr_in serv_addr;
78 bzero((
char *) &serv_addr,
sizeof(serv_addr));
79 serv_addr.sin_family = AF_INET;
80 serv_addr.sin_port = htons(port);
81 serv_addr.sin_addr.s_addr = INADDR_ANY;
82 if (bind(
fd_, (
struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0) {
84 ERROR(
"Socket binding");
85 throw std::runtime_error (
"Bind error");