- int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (sockfd == -1)
- err(EXIT_FAILURE, "Could not create socket");
-
- struct sockaddr_un addr;
- memset(&addr, 0, sizeof(struct sockaddr_un));
- addr.sun_family = AF_LOCAL;
- strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
- if (connect(sockfd, (const struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0)
- err(EXIT_FAILURE, "Could not connect to i3 on socket \"%s\"", socket_path);
-