[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] lwip tcp hangup
From: |
vincent cui |
Subject: |
Re: [lwip-users] lwip tcp hangup |
Date: |
Thu, 1 Sep 2011 08:52:19 +0000 |
Simon
The httphandler definition as followed, please help me to check ...
It only return a daynamic web page....
For FRTOS configuration, I configure it as PREEMPTION
void httphandler(void *pvArg)
{
int nbytes;
int8_t *ptr;
struct tm time;
int clientfd = *((int *)pvArg);
#if LWIP_TCP_KEEPALIVE
lwip_setsockopt(clientfd, SOL_SOCKET, TCP_KEEPIDLE, (void
*)&tcp_keepIdle, sizeof(tcp_keepIdle));
lwip_setsockopt(clientfd, SOL_SOCKET, TCP_KEEPINTVL, (void
*)&tcp_keepIntvl, sizeof(tcp_keepIntvl));
lwip_setsockopt(clientfd, SOL_SOCKET, TCP_KEEPCNT, (void
*)&tcp_keepCount, sizeof(tcp_keepCount));
#endif
lwip_setsockopt (clientfd, SOL_SOCKET, SO_RCVTIMEO, &web_rcvtimeo,
sizeof(uint32_t));
nbytes = lwip_recv (clientfd, webpage, sizeof(WebSide),0);
if (nbytes>0)
{
if (strstr ((void *)webpage, "GET" ) != NULL)
{
memcpy (webpage , WebSide ,sizeof(WebSide));
if( (ptr = memstrExt( (void
*)webpage,"AD8%",strlen("AD8%"),sizeof(webpage)) ) != NULL)
{
time = Time_GetCalendarTime();
sprintf ((void *)ptr, "%d-%d-%d
%02d:%02d:%02d", time.tm_year, \
time.tm_mon+1, time.tm_mday,\
time.tm_hour, time.tm_min,
time.tm_sec);
}
send (clientfd, "HTTP/1.1 200 OK\r\nContent-type:
text/html\r\n\r\n", strlen("HTTP/1.1 200 OK\r\nContent-type:
text/html\r\n\r\n"), 0); //发送HTPP请求什么的
send (clientfd,webpage,strlen(WebSide) ,0);
}
}
lwip_close (clientfd);
vTaskDelete(NULL);
}
锘?Vincent Cui
Sr.Firmware Engineer
Mobile: +8613482482211
Tel: +86 21 34612525x6104
Fax: +86 21 34619770
E-Mail: address@hidden
Shanghai EnLogic Electric Technology Co., Ltd.
Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai,
200233
http://www.enlogic.com
-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Simon Goldschmidt
Sent: 2011年9月1日 16:50
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip tcp hangup
vincent cui <address@hidden> wrote:
> The following code is a piece of my web server, I think it should deal
> with mult-connetion, but the result is not
That code should be OK to handle parallel connections. If it's not, it could be
a problem either in how the 'httphandler' function works or how your OS handles
parallel threads. I'm not familiar with FreeRTOS, however (since I think that's
what you're using).
Simon
BTW: no need to call close() for invalid sockets (i.e. < 0). Since this is an
error condition, you should break the while-loop instead.
BTW2: '0' *is* a valid socket, so your check should be 'if (clientfd >= 0)'.
> while (1)
> {
> clientfd = lwip_accept(lSocket, (struct sockaddr*)&client_addr,
> &addrlen);
> if (clientfd > 0)
> {
> xTaskCreate( httphandler, NULL, 128, (void *)&clientfd,
> HTTP_TASK_PRIORITY, NULL );
> vTaskDelay(100);
> }
> else
> {
> lwip_close (clientfd);
> }
> }
>
> Would you help to check ?
>
> 锘?Vincent Cui
> Sr.Firmware Engineer
> Mobile: +8613482482211
> Tel: +86 21 34612525x6104
> Fax: +86 21 34619770
> E-Mail: address@hidden
> Shanghai EnLogic Electric Technology Co., Ltd.
> Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District,
> Shanghai, 200233
> http://www.enlogic.com
>
> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On Behalf Of Simon
> Goldschmidt
> Sent: 2011年9月1日 16:10
> To: Mailing list for lwIP users
> Subject: Re: [lwip-users] lwip tcp hangup
>
> vincent cui <address@hidden> wrote:
> > I mean I don't make lwIP do mult connection, it always deal with
> > connection one by one
>
> lwIP certainly allows multiple parallel connections, but I don't
> understand what you mean by "making lwIP do mult connection".
>
> Simon
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
> _______________________________________________
> lwip-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/lwip-users
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup,
vincent cui <=
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, FreeRTOS Info, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, Simon Goldschmidt, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, FreeRTOS Info, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01
- Re: [lwip-users] lwip tcp hangup, vincent cui, 2011/09/01