We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
untested. but it compiles
diff --git a/src/Socket/ClientSocket/TimingSocket/TimingSocket.cpp b/src/Socket/ClientSocket/TimingSocket/TimingSocket.cpp index 476ca2d..ed5e2ca 100644 --- a/src/Socket/ClientSocket/TimingSocket/TimingSocket.cpp +++ b/src/Socket/ClientSocket/TimingSocket/TimingSocket.cpp @@ -28,10 +28,29 @@ struct addrinfo* retrieveConnectionCandidates(const std::string& host, int port) return res0; } +#include <sys/un.h> + void Socket::TimingSocket::connect(std::string host, uint16_t port) { this->host = host; this->port = port; - struct addrinfo *res, *res0; + struct addrinfo *res, *res0 = 0; + + if (host.find('/') != std::string::npos) { + sock = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock >= 0) { + struct sockaddr_un addr; + memset(&addr, 0, sizeof(struct sockaddr_un)); + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, host.c_str(), sizeof(addr.sun_path) - 1); + if (::connect(sock, (struct sockaddr*) &addr, sizeof(struct sockaddr_un)) < 0) { + ::close(sock); + sock = -1; + } + /* socket opened */ + state = SOCKSTATE_ESTABLISHED; + } + } else { + res0 = retrieveConnectionCandidates(host, port); sock = -1; for (res = res0; res; res = res->ai_next) { @@ -50,6 +69,8 @@ void Socket::TimingSocket::connect(std::string host, uint16_t port) { state = SOCKSTATE_ESTABLISHED; break; } + } + if (sock < 0) { throw std::runtime_error(std::string("Unable to open socket for host \""+host+":"+std::to_string(port)+"\"")); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
untested. but it compiles
The text was updated successfully, but these errors were encountered: