diff options
author | David Pursell <dpursell@google.com> | 2016-02-02 19:36:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-02-02 19:36:44 +0000 |
commit | f971b6a24b2d785187cf98cb002b9aee9ab6b2a7 (patch) | |
tree | 97a3483c1c8cb5a57c82633723b9f8a84a2ab9cd /fastboot/socket.cpp | |
parent | d95ecfc432206d5408738bb7cbc6eb15e5827d91 (diff) | |
parent | c3a466960ff19bbf9b28b4d069dd0b872d4165d8 (diff) |
Merge "fastboot: socket testing improvements."
Diffstat (limited to 'fastboot/socket.cpp')
-rw-r--r-- | fastboot/socket.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fastboot/socket.cpp b/fastboot/socket.cpp index d41f1fe6f..0a3ddfa2f 100644 --- a/fastboot/socket.cpp +++ b/fastboot/socket.cpp @@ -28,6 +28,7 @@ #include "socket.h" +#include <android-base/errors.h> #include <android-base/stringprintf.h> Socket::Socket(cutils_socket_t sock) : sock_(sock) {} @@ -77,6 +78,10 @@ ssize_t Socket::ReceiveAll(void* data, size_t length, int timeout_ms) { return total; } +int Socket::GetLocalPort() { + return socket_get_local_port(sock_); +} + // Implements the Socket interface for UDP. class UdpSocket : public Socket { public: @@ -210,3 +215,12 @@ std::unique_ptr<Socket> Socket::NewServer(Protocol protocol, int port) { return nullptr; } + +std::string Socket::GetErrorMessage() { +#if defined(_WIN32) + DWORD error_code = WSAGetLastError(); +#else + int error_code = errno; +#endif + return android::base::SystemErrorCodeToString(error_code); +} |