diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-22 16:38:49 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-22 16:41:31 +0100 |
commit | 28f1486627f554cef4026af63dcbce1b9bdae30b (patch) | |
tree | 96ddeed26f45989b7be2a361f950033eb67c93e5 /Libraries/LibCore | |
parent | 82fd09e8fe41c5ee51df10443b2b87eb9d3ee327 (diff) | |
download | serenity-28f1486627f554cef4026af63dcbce1b9bdae30b.zip |
LibCore: Log a more helpful message when Socket::connect() fails
Fixes #1272.
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r-- | Libraries/LibCore/Socket.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Libraries/LibCore/Socket.cpp b/Libraries/LibCore/Socket.cpp index 35590d541a..11446da741 100644 --- a/Libraries/LibCore/Socket.cpp +++ b/Libraries/LibCore/Socket.cpp @@ -113,6 +113,8 @@ bool Socket::connect(const SocketAddress& address) saddr.sun_family = AF_LOCAL; strcpy(saddr.sun_path, address.to_string().characters()); + m_destination_address = address; + return common_connect((const sockaddr*)&saddr, sizeof(saddr)); } @@ -137,7 +139,9 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen) }; return true; } - perror("Socket::common_connect: connect"); + int saved_errno = errno; + fprintf(stderr, "Core::Socket: Failed to connect() to %s: %s\n", destination_address().to_string().characters(), strerror(saved_errno)); + errno = saved_errno; return false; } #ifdef CSOCKET_DEBUG |