diff options
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); +} |