how to use Relay to connect peers which are unreachable. - WeOnlyDo Discussion board

how to use Relay to connect peers which are unreachable. (General questions)

by ardar, Thursday, May 19, 2016, 04:38 (3108 days ago) @ Jasmine

thank you for replying, i tried to use the VPNRelay and succeed to connect, but i'd like to use the TCPHandler and the Relay Server to make the connection between peers and server more stable. i checked some document about TCHandler and as my understanding, i write code like this(fake code):



m_tcpHandler = m_VPN.GetTCPHandler();
m_tcpHandler.put_RemoteTCPHost("xxx.xxx.xxx.xxx");//a public relay server's ip
m_tcpHandler.put_RemoteTCPPort(800); //a public relay server's port
m_tcpHandler.put_LocalUDPPort( 8001 );
m_tcpHandler.put_LocalTCPPort( 8002 );

m_wodVPN.Start("myId", "myPass");

m_tcpHandler.Connect("remoteId");

// then wait for OnTCPConnected event.
void OnTCPConnected(LPCTSTR szRemoteId)
{
   if(szRemoteId!=NULL)
   {
       m_wodVPN.Connect("127.0.0.1", 8001);
   }
}

is this correct? i m confused about the m_wodVPN.Connect, should i use the local ip and 8001(the LocalUDPPort of tcpHandler), this code i run, the TCPRelay server( from source code project TcpRelay) prints that "Found match for myId ==> remoteId", but the m_wodVPN.Connect seems not succeed, because after few seconds, the Disconnect event of wodVPN fired. i didn't know what's the problem, can you help to describe some sequence of using the tcphandler, like when can i call the connect of tcphandler and when can i call the wodVPN.Connect?

i really need to use the server to handle some situation of the peers cannot reach each other, thank you!


Complete thread: