aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-06-09 20:38:40 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 22:56:48 +0200
commit68a95ec4ee9ff52e965d408d93069db4667f5604 (patch)
tree209b484c5cb320eafbf915aad573223061729ebd
parentff56a95cb87e8ff91bf8585753948f25458f6a9d (diff)
Bind for rendezvous connection
-rw-r--r--include/sibs/DirectConnection.hpp2
-rw-r--r--src/DirectConnection.cpp10
2 files changed, 6 insertions, 6 deletions
diff --git a/include/sibs/DirectConnection.hpp b/include/sibs/DirectConnection.hpp
index 9786c64..900d419 100644
--- a/include/sibs/DirectConnection.hpp
+++ b/include/sibs/DirectConnection.hpp
@@ -55,7 +55,7 @@ namespace sibs
protected:
int createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind = true);
private:
- void connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc);
+ void connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind);
void removeDisconnectedPeers();
void receiveData();
int receiveDataFromPeer(const int socket, char *output, usize *receivedTotalSize);
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp
index e6b5645..4c14045 100644
--- a/src/DirectConnection.cpp
+++ b/src/DirectConnection.cpp
@@ -60,7 +60,7 @@ namespace sibs
UDT::setsockopt(socket, 0, UDT_MSS, &mss, sizeof(mss));
#endif
- if(bind)
+ if(rendezvous || bind)
{
if(UDT::bind(socket, (sockaddr*)&addressToBind.address, sizeof(addressToBind.address)) == UDT::ERROR)
{
@@ -75,15 +75,15 @@ namespace sibs
void DirectConnections::connectServer(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc)
{
- connect(address, false, true, connectCallbackFunc, receiveDataCallbackFunc);
+ connect(address, false, true, connectCallbackFunc, receiveDataCallbackFunc, false);
}
void DirectConnections::connect(const Ipv4 &address, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc)
{
- connect(address, true, true, connectCallbackFunc, receiveDataCallbackFunc);
+ connect(address, true, true, connectCallbackFunc, receiveDataCallbackFunc, true);
}
- void DirectConnections::connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc)
+ void DirectConnections::connect(const Ipv4 &address, bool rendezvous, bool reuseAddr, PubSubConnectCallback connectCallbackFunc, PubSubReceiveDataCallback receiveDataCallbackFunc, bool bind)
{
std::thread([this, address, rendezvous, reuseAddr, connectCallbackFunc, receiveDataCallbackFunc]()
{
@@ -91,7 +91,7 @@ namespace sibs
UDTSOCKET socket;
try
{
- socket = createSocket(Ipv4(nullptr, port), rendezvous, reuseAddr, false);
+ socket = createSocket(Ipv4(nullptr, port), rendezvous, reuseAddr, bind);
}
catch(SocketCreateException &e)
{