update
This commit is contained in:
parent
0da36b9b8b
commit
f1bf409981
7
das-dn/third_party/AdsLib/Sockets.cpp
vendored
7
das-dn/third_party/AdsLib/Sockets.cpp
vendored
@ -84,7 +84,7 @@ uint32_t getIpv4(const std::string& addr)
|
||||
InitSocketLibrary();
|
||||
const auto status = getaddrinfo(addr.c_str(), nullptr, &addrinfo, &res);
|
||||
if (status) {
|
||||
throw std::runtime_error("Invalid IPv4 address or unknown hostname: " + addr);
|
||||
//throw std::runtime_error("Invalid IPv4 address or unknown hostname: " + addr);
|
||||
}
|
||||
|
||||
const auto value = ((struct sockaddr_in*)res->ai_addr)->sin_addr.s_addr;
|
||||
@ -239,11 +239,14 @@ Frame& Socket::read(Frame& frame, timeval* timeout)
|
||||
bool Socket::Select(timeval* timeout)
|
||||
{
|
||||
/* prepare socket set for select() */
|
||||
if (!IsValid()) {
|
||||
LOG_ERROR("Socket is invalid: " << std::dec << m_Socket);
|
||||
return false;
|
||||
}
|
||||
fd_set readSockets;
|
||||
FD_ZERO(&readSockets);
|
||||
FD_SET(m_Socket, &readSockets);
|
||||
|
||||
if (!IsValid()) return false;
|
||||
/* wait for receive data */
|
||||
const int state = NATIVE_SELECT(m_Socket + 1, &readSockets, nullptr, nullptr, timeout);
|
||||
if (0 == state) {
|
||||
|
@ -65,7 +65,7 @@ long AmsRouter::ConnectTarget(AmsNetId ams, const std::string& host)
|
||||
|
||||
connection_attempts[ams] = {};
|
||||
lock.unlock();
|
||||
try {
|
||||
// try {
|
||||
//AmsConnection is created and try to connect remote host
|
||||
auto new_connection = std::unique_ptr<AmsConnection>(new AmsConnection {*this, hostAddresses.get()});
|
||||
if(new_connection.get() == nullptr || new_connection.get()->IsConnected() == false){
|
||||
@ -89,13 +89,13 @@ long AmsRouter::ConnectTarget(AmsNetId ams, const std::string& host)
|
||||
}
|
||||
|
||||
return -1;//
|
||||
} catch (std::exception& e) {
|
||||
std::cout<<"AmsRouter::AddRoute(Exception) is occured."<<"\n";
|
||||
lock.lock();
|
||||
connection_attempts.erase(ams);
|
||||
connection_attempt_events.notify_all();
|
||||
throw e;
|
||||
}
|
||||
// } catch (std::exception& e) {
|
||||
// std::cout<<"AmsRouter::AddRoute(Exception) is occured."<<"\n";
|
||||
// lock.lock();
|
||||
// connection_attempts.erase(ams);
|
||||
// connection_attempt_events.notify_all();
|
||||
// throw e;
|
||||
// }
|
||||
}
|
||||
|
||||
void AmsRouter::DisconnectTarget(const AmsNetId& ams)
|
||||
|
Loading…
Reference in New Issue
Block a user