lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] lwip1.30+ucos2.86 on luminary lm3s8962


From: greencity
Subject: [lwip-users] lwip1.30+ucos2.86 on luminary lm3s8962
Date: Thu, 4 Dec 2008 15:00:19 +0800

Hi all:

There is something wrong with my process. Please help me. Thanks a lot.

I am porting lwip1.30 and ucos2.86 on luminary lm3s8962. The RTOS and stack begin to work now and can ping with each other. So I want to build a simple http server on it. The code below is my http connect task and connect process function. They are written with reference to the httpserver-netconn.c in lwip contrib-1.30.

I use realview MDK3.24 to build the target and use lm link to debug.When the program is runningI find that http server only can connect one time. And when the connect is closed the server send RST package to web browser(MAXTHON). After this I refresh the web browser but the server can not response to this connect request. Why??

 

static void Http_Task(void  *parg) 
{
 extern void http_process(struct netconn *pxNetCon);
 struct netconn *pxHTTPListener, *pxNewConnection;
 
 /* Create a new tcp connection handle */

  pxHTTPListener = netconn_new( NETCONN_TCP );
 netconn_bind(pxHTTPListener, NULL, 80 );
 netconn_listen( pxHTTPListener );

 while(1)
 {
  /* Wait for connection. */
  pxNewConnection=netconn_accept(pxHTTPListener);
  http_process(pxNewConnection);
  netconn_delete(pxNewConnection);
 }

 

extern void
http_process(struct netconn *conn) {
  struct netbuf *inbuf;
  char *buf;
  u16_t buflen;
 
  /* Read the data from the port, blocking if nothing yet there.
   We assume the request (the part we care about) is in one netbuf */
  inbuf = netconn_recv(conn);
 
  if (netconn_err(conn) == ERR_OK) {
    netbuf_data(inbuf, &buf, &buflen);
   
    /* Is this an HTTP GET command? (only check the first 5 chars, since
    there are other formats for GET, and we're keeping it very simple )*/
    if (buflen>=5 &&
        buf[0]=='G' &&
        buf[1]=='E' &&
        buf[2]=='T' &&
        buf[3]==' ' &&
        buf[4]=='/' ) {
     
      /* Send the HTML header
             * subtract 1 from the size, since we dont send the \0 in the string
             * NETCONN_NOCOPY: our data is const static, so no need to copy it
       */
      netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY);
     
      /* Send our HTML page */
      netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY);
    }
  }
  /* Close the connection (server closes in HTTP) */
  netconn_close(conn);
 
  /* Delete the buffer (netconn_recv gives us ownership,
   so we have to make sure to deallocate the buffer) */
  netbuf_delete(inbuf);
}


reply via email to

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