hi all:   I am porting lwip1.30 and ucos2.86 on luminary lm3s8962. the RTOS and 
stack begin work and can ping. So I want to build a sample http server on 
it.the code below is my http connect task and connect process function. they 
are writed referenced the httpserver-netconn.c in lwip contrib-1.30.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 voidhttp_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);}I use realview MDK3.24 built 
the target and use lm link to debug.when my program runing  I find 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 for this connect request.why??
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to