diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-06-09 16:52:38 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-06-09 16:54:11 +0200 |
commit | 6675ebd2964af48410a4843784b092026101de87 (patch) | |
tree | f2d583201146a3f382765f681554757ec27402d5 /src | |
parent | f5cfb3d6ef967a3c5547d7eb417a9a028c520d34 (diff) |
Change connection type to tcp, perhaps udt requires that
Diffstat (limited to 'src')
-rw-r--r-- | src/DirectConnection.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp index 6872c27..ede5251 100644 --- a/src/DirectConnection.cpp +++ b/src/DirectConnection.cpp @@ -39,10 +39,10 @@ namespace sibs UDT::cleanup(); } - int DirectConnections::createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr) + int DirectConnections::createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind) { Log::debug("UDT: Creating socket for ipv4 address %s, port: %d", addressToBind.getAddress().c_str(), addressToBind.getPort()); - UDTSOCKET socket = UDT::socket(AF_INET, SOCK_STREAM, IPPROTO_UDP); + UDTSOCKET socket = UDT::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(socket == UDT::INVALID_SOCK) { std::string errMsg = "UDT: Failed to create socket, error: "; @@ -60,11 +60,14 @@ namespace sibs UDT::setsockopt(socket, 0, UDT_MSS, &mss, sizeof(mss)); #endif - if(UDT::bind(socket, (sockaddr*)&addressToBind.address, sizeof(addressToBind.address)) == UDT::ERROR) + if(bind) { - std::string errMsg = "UDT: Failed to bind, error: "; - errMsg += UDT::getlasterror_desc(); - throw SocketCreateException(errMsg); + if(UDT::bind(socket, (sockaddr*)&addressToBind.address, sizeof(addressToBind.address)) == UDT::ERROR) + { + std::string errMsg = "UDT: Failed to bind, error: "; + errMsg += UDT::getlasterror_desc(); + throw SocketCreateException(errMsg); + } } return socket; @@ -88,7 +91,7 @@ namespace sibs UDTSOCKET socket; try { - socket = createSocket(Ipv4(nullptr, port), rendezvous, reuseAddr); + socket = createSocket(Ipv4(nullptr, port), rendezvous, reuseAddr, false); } catch(SocketCreateException &e) { @@ -158,16 +161,21 @@ namespace sibs std::vector<char> data; data.reserve(MAX_RECEIVED_DATA_SIZE); + Log::debug("DirectConnections::recieveData(): waiting for events"); std::set<UDTSOCKET> readfds; while(alive) { - int numfsReady = UDT::epoll_wait(eid, &readfds, nullptr, 250); + int numfsReady = UDT::epoll_wait(eid, &readfds, nullptr, 1000); if(numfsReady == 0) + { continue; + } else if(numfsReady == -1) { if(UDT::getlasterror_code() == UDT::ERRORINFO::ETIMEOUT) + { continue; + } else { Log::error("UDT: Stop receiving data, got error: %s", UDT::getlasterror_desc()); |