mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 23:25:32 -04:00
The first commit of the new UDP Connection methods and
the rewrite of the retroshare core networking stack. This check-in commits the changes to the TCPonUCP code. This library has been significantly modified to support multiple UDP "connections" from a single port. This requires some trickery and a listener thread. Code to "STUN" peers was also added. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@305 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b0f31a1340
commit
de0ce110b9
14 changed files with 1610 additions and 658 deletions
|
@ -115,33 +115,36 @@ int main(int argc, char **argv)
|
|||
std::cerr << "Local Address: " << laddr << std::endl;
|
||||
std::cerr << "Remote Address: " << raddr << std::endl;
|
||||
|
||||
//LossyUdpLayer udpl(laddr, 0.01);
|
||||
UdpLayer udpl(laddr);
|
||||
if (!udpl.openSocket())
|
||||
UdpSorter udps(laddr);
|
||||
if (!udps.okay())
|
||||
{
|
||||
std::cerr << "Cannot Open Local Address: " << laddr << std::endl;
|
||||
std::cerr << "UdpSorter not Okay (Cannot Open Local Address): " << laddr << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
udpl.setRemoteAddr(raddr);
|
||||
|
||||
TcpStream tcp(&udpl);
|
||||
TcpStream tcp(&udps);
|
||||
udps.addUdpPeer(&tcp, raddr);
|
||||
|
||||
if (toConnect)
|
||||
{
|
||||
tcp.connect();
|
||||
tcp.connect(raddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
tcp.listenfor(raddr);
|
||||
}
|
||||
|
||||
while(!tcp.isConnected())
|
||||
{
|
||||
sleep(1);
|
||||
std::cerr << "Waiting for TCP to Connect!" << std::endl;
|
||||
udpl.status(std::cerr);
|
||||
udps.status(std::cerr);
|
||||
tcp.status(std::cerr);
|
||||
tcp.tick();
|
||||
}
|
||||
std::cerr << "TCP Connected***************************" << std::endl;
|
||||
udpl.status(std::cerr);
|
||||
udps.status(std::cerr);
|
||||
tcp.status(std::cerr);
|
||||
std::cerr << "TCP Connected***************************" << std::endl;
|
||||
|
||||
|
@ -161,7 +164,7 @@ int main(int argc, char **argv)
|
|||
while(!done)
|
||||
{
|
||||
//sleep(1);
|
||||
usleep(10000);
|
||||
usleep(100000);
|
||||
//usleep(1000);
|
||||
if (blockread != true)
|
||||
{
|
||||
|
@ -196,8 +199,8 @@ int main(int argc, char **argv)
|
|||
|
||||
while(!tcp.widle())
|
||||
{
|
||||
sleep(1);
|
||||
//usleep(10000);
|
||||
//sleep(1);
|
||||
usleep(100000);
|
||||
//usleep(1000);
|
||||
tcp.tick();
|
||||
if (count++ % 10 == 0)
|
||||
|
@ -220,7 +223,7 @@ int main(int argc, char **argv)
|
|||
while(1)
|
||||
{
|
||||
//sleep(1);
|
||||
usleep(10000);
|
||||
usleep(100000);
|
||||
//usleep(1000);
|
||||
//int writesize = bufsize;
|
||||
int ret;
|
||||
|
@ -258,7 +261,9 @@ int main(int argc, char **argv)
|
|||
while((stayOpen) || (!tcp.ridle()))
|
||||
{
|
||||
tcp.tick();
|
||||
sleep(1);
|
||||
//sleep(1);
|
||||
usleep(100000);
|
||||
//usleep(1000);
|
||||
if (count++ % 10 == 0)
|
||||
{
|
||||
std::cerr << "Waiting for Idle()" << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue