From 11db95f0d12fb696d890a63a887f93b4beb14b5b Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 11 Apr 2004 18:58:00 +0000 Subject: Fixes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@552 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/connection.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 156a5fcea..a7f7ed0a1 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -148,10 +148,24 @@ bool connection::SendPacket(char *message, char* host, int port, long ourkey) host_address.sin_family=AF_INET; host_address_size=sizeof(host_address); - if (recvfrom(fd,&p2,sizeof(p2),0,(sockaddr*)&host_address,&host_address_size)<0) + // wait for ack, or timeout. + // if reached a timeout, send again. + // the packet id in the ack must match that in the original packet + // this MUST operate in lock/step fashion!!! + int cycles = 0; + packet p2; + do { - return false; + fd_set sfd; + timeval tval; + tval.tv_usec = 100; + tval.tv_sec = 0; + FD_ZERO(&sfd); + FD_SET(fd,&sfd); + int res = select(65535, &sfd, NULL, NULL, &tval); + cycles++; } + while ((recvfrom(fd,&p2,sizeof(p2),0,(sockaddr*)&host_address,&host_address_size)<0) && (cycles < 10)); if (cycles >= 10) { -- cgit v1.2.3