lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Question about socket send


From: megatron
Subject: [lwip-users] Question about socket send
Date: Wed, 15 Jul 2009 23:44:04 -0700 (PDT)

Hi,all:
    This is my first post in this forum.Please forgive my poor English,I
hope someone can understand me. I'm new in lwip and TCP/IP,I hope  my
question is  not too stupid.
I've just port lwip 1.3.0 on ucos-ii on lpc2368.I make a simple test
program,it runs as a ucos-ii task:

 void  task1 (void *p_arg)
{
  int     iSock,tSock;
  struct sockaddr_in   server,client;
  u8_t  recvbuf[4000];
  u32_t  len;
  u8_t   step = 1;
  
  server.sin_family = AF_INET;
  server.sin_port = htons(5000);
  server.sin_addr.s_addr = htonl(INADDR_ANY);
  
  tSock = bind( iSock, (struct sockaddr *)&server, sizeof(server));
  tSock = listen(iSock,0); 
  
  
  while(1)
  {
     switch(step)
     {
        case 1:
           len = sizeof(client);
           tSock = accept(iSock,(struct sockaddr*)&client,&len); 
           step = 2;
           break;
        case 2:
           len = recv(tSock,recvbuf,2000,0);
           if(len <= 0)
           {
              closesocket(tSock);
              step = 1;
           }
           else
           {
              len = send(tSock,recvbuf,len,0);  
              if(len <= 0)
              {
                  closesocket(tSock);
                  step = 1;
               }
           
           }
         break;
     }
  }          
}

The test task makes a TCP server on port 5000,receives data from client and
sends it back.On a PC with WINXP,there is a  TCP test software,it can send
data of size from 1 to 32K bytes,and can send the data repeatedly.I start
this software as a client ,connect to lwip ,and send  data repeatedly.LWIP
can send the data back.But after some while,there is no data be send
back,and then no data is send out,and then the connection disconnected.The
bigger the size of data,the quicker that LWIP stops responing. I try to
debug,and finally I found:
socket send() calls netconn_write(),and netconn_write() calls a macor
TCPIP_APIMSG(&msg),which is defined as tcpip_apimsg(m), tcpip_apimsg(m)
calls sys_arch_sem_wait(apimsg->msg.conn->op_completed, 0), but this
function never returned,so the task is blocked here forever.  
my lwipopts.h mainly is : 
MEM_SIZE                               6000
MEMP_NUM_PBUF                      20 
MEMP_NUM_TCP_PCB                 6
MEMP_NUM_TCP_PCB_LISTEN      5 
MEMP_NUM_TCP_SEG                16 
MEMP_NUM_SYS_TIMEOUT         10 
MEMP_NUM_NETBUF                  4 
MEMP_NUM_NETCONN               10
MEMP_NUM_TCPIP_MSG_API      16
MEMP_NUM_TCPIP_MSG_INPKT   16

TCP_MSS                       1460
TCP_SND_BUF                 4*TCP_MSS
TCP_SND_QUEUELEN        (4 * TCP_SND_BUF/TCP_MSS)
TCP_WND                       2*TCP_MSS                      

My quesion is :
Do I use socket recv() and send() not correctly? Or there is some errors in
my lwipopts.h?

thanks for your help!

  
-- 
View this message in context: 
http://www.nabble.com/Question-about-socket-send-tp24473527p24473527.html
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

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