lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Problem with lwip_close in TCP


From: Frédéric BERNON
Subject: [lwip-users] Problem with lwip_close in TCP
Date: Tue, 13 Jun 2006 16:02:12 +0200

Hello,

I port LwIP 1.1.1 on a Philips DSP with OS support. I got a problem when I use 
"BSD sockets layer" to send data.
My application is a HTTP Server which only send one document per connection. I 
also use TCP_NODELAY.

When I got an incomming connection (by "accept"), I send the requested 
document, with a code like this :

////////////////////////////////////////////////////////////////////////////////
static bool Send( int hSocket, void* lpData, u32_t dwSize, u32_t* 
lpdwNbBytesSended)
////////////////////////////////////////////////////////////////////////////////
{ //  Variables de travail
  bool   bResult          = true;
  u32_t  dwRestToSent     = dwSize;
  u8_t*  lpInternalBuffer = lpData;
  int    iSent;
  
  while((dwRestToSent != 0) && (hSocket>=0))
   { iSent = send( hSocket, (char*)lpInternalBuffer, MIN( 1024, dwRestToSent), 
0);
     if ( iSent < 0)
      { hSocket = -1;
        printf("HTTPSERVER: Send Error - %i\n", iSent);
      }
     else
      { dwRestToSent -= (u32_t) iSent;
        lpInternalBuffer += iSent;
      }
   } 
  
  if (lpdwNbBytesSended!=NULL) (*lpdwNbBytesSended)=(dwSize-dwRestToSent);
  
  if (dwRestToSent!=0)
   { printf("HTTPSERVER: Send Error - %i\n", errno);
     bResult=false;
   }
  return bResult;
}

After using this code to send my document, I do a lwip_close on my socket. The 
problem is that all my data is not sent if I don't do a "sleep" between my 
"Send" call, and the lwip_close. With a 10ms "sleep" before the lwip_close, all 
my datas is received. It seems that all "enqueued" tcp datas are dropped when I 
do the lwip_close.

Is there something missing in my code, or how to be sure that all my datas sent 
by TCP are received before the socket's close ?

Thank you for your comments...
 
  
====================================
Frédéric BERNON 
HYMATOM SA 
Chef de projet informatique 
Microsoft Certified Professional 
Tél. : +33 (0)4-67-87-61-10 
Fax. : +33 (0)4-67-70-85-44 
Email : address@hidden 
Web Site : http://www.hymatom.fr 
====================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]