mirror of https://github.com/aria2/aria2
2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added the function to get error message from socket. * src/SocketCore.cc * src/SocketCore.hpull/1/head
parent
72da43e47f
commit
8687877139
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -278,6 +278,8 @@ public:
|
|||
bool operator<(const SocketCore& s) {
|
||||
return sockfd < s.sockfd;
|
||||
}
|
||||
|
||||
std::string getSocketError() const;
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
Loading…
Reference in New Issue