* [ECOS] __tcp_close() can't close connection in Redboot
@ 2005-10-12 11:19 Huang Sun I
2005-10-12 12:53 ` [ECOS] " Grant Edwards
0 siblings, 1 reply; 8+ messages in thread
From: Huang Sun I @ 2005-10-12 11:19 UTC (permalink / raw)
To: ecos-discuss
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=big5, Size: 1570 bytes --]
Hi,
I am trying to build up httpd service in RedBoot.
And I met problem that I can't close connection by
calling __tcp_close() after replying data to
client,and the httpd sock state is always TIME_WAIT.
The client http can't get response from server after
recevive replying.I have to open another client http
to browser,but only once,problem is the same with
above
I described.
The following are rough code structure..
1> into listening state by calling __tcp_listen().
2>Checking TCP incoming connection
httpd_accept()
{
if (!is_idle) return;
if (!have_net) return;
__tcp_poll();
if (httpd_state != httpd_sock.state) {
// Something has changed
if (httpd_sock.state == _ESTABLISHED) {
// A new connection has arrived
//check Rx data and response
// close connection by calling
__tcp_close() .
}
if (httpd_sock.state == _CLOSED) {
// Get ready for another connection
//into listening state by calling
__tcp_listen().
}
}
httpd_state = httpd_sock.state;
}
RedBoot_idle(httpd_accept, RedBoot_IDLE_HTTPD/* 6000
*/);
Do I miss any procedure or other way that could fix
it?
thank you!
Huang Sun I
___________________________________________________ ×îаæ Yahoo!ÆæĦ¼´rÍ¨Ó 7.0 beta£¬ÃâÙM¾W·ëÔÈÎÄã´ò£¡ http://messenger.yahoo.com.tw/beta.html
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 11:19 [ECOS] __tcp_close() can't close connection in Redboot Huang Sun I
@ 2005-10-12 12:53 ` Grant Edwards
2005-10-12 13:16 ` Andrew Lunn
0 siblings, 1 reply; 8+ messages in thread
From: Grant Edwards @ 2005-10-12 12:53 UTC (permalink / raw)
To: ecos-discuss
In gmane.os.ecos.general, you wrote:
> I am trying to build up httpd service in RedBoot.
> And I met problem that I can't close connection by
> calling __tcp_close() after replying data to
> client,and the httpd sock state is always TIME_WAIT.
Right.
After you close a tcp connection (you send a FIN packet and
receive a FIN back) the state is _supposed_ to be TIME_WAIT.
http://tangentsoft.net/wskfaq/articles/debugging-tcp.html
--
Grant Edwards grante Yow! Mr and Mrs PED, can
at I borrow 26.7
visi.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 12:53 ` [ECOS] " Grant Edwards
@ 2005-10-12 13:16 ` Andrew Lunn
2005-10-12 13:28 ` Gary Thomas
2005-10-12 13:30 ` Grant Edwards
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Lunn @ 2005-10-12 13:16 UTC (permalink / raw)
To: Grant Edwards; +Cc: ecos-discuss
On Wed, Oct 12, 2005 at 07:55:11AM -0500, Grant Edwards wrote:
> In gmane.os.ecos.general, you wrote:
>
> > I am trying to build up httpd service in RedBoot.
> > And I met problem that I can't close connection by
> > calling __tcp_close() after replying data to
> > client,and the httpd sock state is always TIME_WAIT.
>
> Right.
>
> After you close a tcp connection (you send a FIN packet and
> receive a FIN back) the state is _supposed_ to be TIME_WAIT.
>
> http://tangentsoft.net/wskfaq/articles/debugging-tcp.html
The purpose of this is to catch old packets still floating around the
network including retransmitted FIN packets.
Normally this is not a problem. The server goes back to its listen
socket and accepts the next connection. After 2x maximum segment
lifetime the old socket in TIME_WAIT is destroyed.
I don't know the redboot tcp stack. Does it implement the same
concept? ie simply accept the next connection waiting on the listen
socket?
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 13:16 ` Andrew Lunn
@ 2005-10-12 13:28 ` Gary Thomas
2005-10-12 13:33 ` Grant Edwards
2005-10-12 13:30 ` Grant Edwards
1 sibling, 1 reply; 8+ messages in thread
From: Gary Thomas @ 2005-10-12 13:28 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Grant Edwards, eCos Discussion
On Wed, 2005-10-12 at 15:16 +0200, Andrew Lunn wrote:
> On Wed, Oct 12, 2005 at 07:55:11AM -0500, Grant Edwards wrote:
> > In gmane.os.ecos.general, you wrote:
> >
> > > I am trying to build up httpd service in RedBoot.
> > > And I met problem that I can't close connection by
> > > calling __tcp_close() after replying data to
> > > client,and the httpd sock state is always TIME_WAIT.
> >
> > Right.
> >
> > After you close a tcp connection (you send a FIN packet and
> > receive a FIN back) the state is _supposed_ to be TIME_WAIT.
> >
> > http://tangentsoft.net/wskfaq/articles/debugging-tcp.html
>
> The purpose of this is to catch old packets still floating around the
> network including retransmitted FIN packets.
>
> Normally this is not a problem. The server goes back to its listen
> socket and accepts the next connection. After 2x maximum segment
> lifetime the old socket in TIME_WAIT is destroyed.
>
> I don't know the redboot tcp stack. Does it implement the same
> concept? ie simply accept the next connection waiting on the listen
> socket?
RedBoot hangs once it sees the CLOSE_WAIT condition. You need to
continually call __tcp_poll() which will eventually flush the connection
which then goes to CLOSED. At that time, you can create a new
connection.
Note: this code is untested for more than one active TCP connection,
so beware.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 13:28 ` Gary Thomas
@ 2005-10-12 13:33 ` Grant Edwards
2005-10-12 13:37 ` Gary Thomas
0 siblings, 1 reply; 8+ messages in thread
From: Grant Edwards @ 2005-10-12 13:33 UTC (permalink / raw)
To: ecos-discuss
In gmane.os.ecos.general, you wrote:
> RedBoot hangs once it sees the CLOSE_WAIT condition.
I've never seen that happen.
> You need to continually call __tcp_poll() which will
> eventually flush the connection which then goes to CLOSED.
You have to continually call __tcp_poll() no matter what state
the socket is, since RedBoot is single-threaded.
> At that time, you can create a new connection.
>
> Note: this code is untested for more than one active TCP connection,
> so beware.
It worked OK for me. :)
--
Grant Edwards grante Yow! My forehead feels
at like a PACKAGE of moist
visi.com CRANBERRIES in a remote
FRENCH OUTPOST!!
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 13:33 ` Grant Edwards
@ 2005-10-12 13:37 ` Gary Thomas
2005-10-12 15:07 ` Huang Sun I
0 siblings, 1 reply; 8+ messages in thread
From: Gary Thomas @ 2005-10-12 13:37 UTC (permalink / raw)
To: Grant Edwards; +Cc: eCos Discussion
On Wed, 2005-10-12 at 08:34 -0500, Grant Edwards wrote:
> In gmane.os.ecos.general, you wrote:
>
> > RedBoot hangs once it sees the CLOSE_WAIT condition.
>
> I've never seen that happen.
You won't - it just won't look for another 'telnet' session
when the current one closes until it's completely closed.
>
> > You need to continually call __tcp_poll() which will
> > eventually flush the connection which then goes to CLOSED.
>
> You have to continually call __tcp_poll() no matter what state
> the socket is, since RedBoot is single-threaded.
>
> > At that time, you can create a new connection.
> >
> > Note: this code is untested for more than one active TCP connection,
> > so beware.
>
> It worked OK for me. :)
Nice to know.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 13:37 ` Gary Thomas
@ 2005-10-12 15:07 ` Huang Sun I
0 siblings, 0 replies; 8+ messages in thread
From: Huang Sun I @ 2005-10-12 15:07 UTC (permalink / raw)
To: ecos-discuss
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=big5, Size: 1931 bytes --]
Hi,
thanks for replying.
After __tcp_close(),I keep calling __tcp_poll() until
state is _CLOSED. But it seems endless,even setup
reuse option to 1sec in sock,the state is still
TIME_WAIT..,
Have you met this situation before?
Could force to destory the state to _CLOSED?
If so,is there any potential problem?
thank you
Sam
--- Gary Thomas <gary@mlbassoc.com> »¡¡G
> On Wed, 2005-10-12 at 08:34 -0500, Grant Edwards
> wrote:
> > In gmane.os.ecos.general, you wrote:
> >
> > > RedBoot hangs once it sees the CLOSE_WAIT
> condition.
> >
> > I've never seen that happen.
>
> You won't - it just won't look for another 'telnet'
> session
> when the current one closes until it's completely
> closed.
>
> >
> > > You need to continually call __tcp_poll() which
> will
> > > eventually flush the connection which then goes
> to CLOSED.
> >
> > You have to continually call __tcp_poll() no
> matter what state
> > the socket is, since RedBoot is single-threaded.
> >
> > > At that time, you can create a new connection.
> > >
> > > Note: this code is untested for more than one
> active TCP connection,
> > > so beware.
> >
> > It worked OK for me. :)
>
> Nice to know.
>
> --
>
------------------------------------------------------------
> Gary Thomas | Consulting for the
> MLB Associates | Embedded world
>
------------------------------------------------------------
>
>
> --
> Before posting, please read the FAQ:
> http://ecos.sourceware.org/fom/ecos
> and search the list archive:
> http://ecos.sourceware.org/ml/ecos-discuss
>
>
___________________________________________________ ×îаæ Yahoo!ÆæĦ¼´rÍ¨Ó 7.0 beta£¬ÃâÙM¾W·ëÔÈÎÄã´ò£¡ http://messenger.yahoo.com.tw/beta.html
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
* [ECOS] Re: __tcp_close() can't close connection in Redboot
2005-10-12 13:16 ` Andrew Lunn
2005-10-12 13:28 ` Gary Thomas
@ 2005-10-12 13:30 ` Grant Edwards
1 sibling, 0 replies; 8+ messages in thread
From: Grant Edwards @ 2005-10-12 13:30 UTC (permalink / raw)
To: ecos-discuss
In gmane.os.ecos.general, you wrote:
> On Wed, Oct 12, 2005 at 07:55:11AM -0500, Grant Edwards wrote:
>> In gmane.os.ecos.general, you wrote:
>>
>> > I am trying to build up httpd service in RedBoot.
>> > And I met problem that I can't close connection by
>> > calling __tcp_close() after replying data to
>> > client,and the httpd sock state is always TIME_WAIT.
>>
>> Right.
>>
>> After you close a tcp connection (you send a FIN packet and
>> receive a FIN back) the state is _supposed_ to be TIME_WAIT.
>>
>> http://tangentsoft.net/wskfaq/articles/debugging-tcp.html
>
> The purpose of this is to catch old packets still floating around the
> network including retransmitted FIN packets.
>
> Normally this is not a problem. The server goes back to its listen
> socket and accepts the next connection. After 2x maximum segment
> lifetime the old socket in TIME_WAIT is destroyed.
Right. You can reduct that period from 120 seconds to 1 second
by setting the reuse option on the socket.
> I don't know the redboot tcp stack. Does it implement the same
> concept? ie simply accept the next connection waiting on the listen
> socket?
After the 2MSL TIME_WAIT is done, you need to call
__tcp_listen() on the socket to make it listen for a new
connection (accept a SYN packet). There is no such thing in
RedBoot as a "listen socket" on which pending connections wait.
IOW, you use a single socket structure to both listen for the
connection and communicate via that connection.
--
Grant Edwards grante Yow! FUN is never having
at to say you're SUSHI!!
visi.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-10-12 15:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12 11:19 [ECOS] __tcp_close() can't close connection in Redboot Huang Sun I
2005-10-12 12:53 ` [ECOS] " Grant Edwards
2005-10-12 13:16 ` Andrew Lunn
2005-10-12 13:28 ` Gary Thomas
2005-10-12 13:33 ` Grant Edwards
2005-10-12 13:37 ` Gary Thomas
2005-10-12 15:07 ` Huang Sun I
2005-10-12 13:30 ` Grant Edwards
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).