2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Added the function to get error message from socket.
	* src/SocketCore.cc
	* src/SocketCore.h
pull/1/head
Tatsuhiro Tsujikawa 2008-09-14 14:26:35 +00:00
parent 72da43e47f
commit 8687877139
3 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added the function to get error message from socket.
* src/SocketCore.cc
* src/SocketCore.h
2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added convenient method RequestGroupMan::getOrCreateServerStat()

View File

@ -768,4 +768,19 @@ ssize_t SocketCore::readDataFrom(char* data, size_t len,
return r;
}
std::string SocketCore::getSocketError() const
{
int error;
SOCKOPT_T optlen = sizeof(error);
if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &optlen) == -1) {
throw DlAbortEx(StringFormat("Failed to get socket error: %s",
errorMsg()).str());
}
if(error != 0) {
return strerror(error);
} else {
return "";
}
}
} // namespace aria2

View File

@ -278,6 +278,8 @@ public:
bool operator<(const SocketCore& s) {
return sockfd < s.sockfd;
}
std::string getSocketError() const;
};
} // namespace aria2