EmbeddedRelated.com
Forums

Open Sockets

Started by Hao Wu March 18, 2012
Hi,

I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
communication centre in this project. UDP client/server, Telnet client, FTP
server, TFTP client must be implemented.

The system is working but seems a bit clunky. The most annoying problem is
that the BL2600 occasionally becomes un-ping-able after running a certain
period. At that time, it's still able to send data out but unable to
receive. And it can't be restored unless a power cycle.

I suspect it may caused by using out of the socket. I have set both the
MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program is
not likely to use so many sockets.

If I disable the Telnet task, this problem won't happen any more.

In the Telnet task, I use sock_alive to detect the status of the socket. If
it returns 0, I consider the Telnet connection being lost, so basically the
code is like:

while(1)
{
VdHitWd(wdID);
if (sock_alive(&s1) == 0)
{
sock_close(&s1);
tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
buf1size);
}
if (sock_alive(&s2) == 0)
{
sock_close(&s2);
tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
buf2size);
}
............
OSTimeDly(OS_TICKS_PER_SEC);
}

Is there anything wrong? And is there anyway to know how many sockets are
being used currently?

Thanks a lot!

Regards,
Hao
Hi Hao,
I have been some issues of this kind also with DC9.62. When i use DC 8.01
everything works right.

Regards
Jesus

De: Hao Wu
Responder a:
Fecha: Mon, 19 Mar 2012 12:44:08 +1100
Para:
Asunto: [rabbit-semi] Open Sockets

Hi,

I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
communication centre in this project. UDP client/server, Telnet client, FTP
server, TFTP client must be implemented.

The system is working but seems a bit clunky. The most annoying problem is
that the BL2600 occasionally becomes un-ping-able after running a certain
period. At that time, it's still able to send data out but unable to
receive. And it can't be restored unless a power cycle.

I suspect it may caused by using out of the socket. I have set both the
MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program is
not likely to use so many sockets.

If I disable the Telnet task, this problem won't happen any more.

In the Telnet task, I use sock_alive to detect the status of the socket. If
it returns 0, I consider the Telnet connection being lost, so basically the
code is like:

while(1)
{
VdHitWd(wdID);
if (sock_alive(&s1) == 0)
{
sock_close(&s1);
tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
buf1size);
}
if (sock_alive(&s2) == 0)
{
sock_close(&s2);
tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
buf2size);
}
............
OSTimeDly(OS_TICKS_PER_SEC);
}

Is there anything wrong? And is there anyway to know how many sockets are
being used currently?

Thanks a lot!

Regards,
Hao
Are you calling tcp_tick(NULL) often enough in your main loop to keep the TCP processes working?
--- In r..., Jesus Manuel Conejo Sarabia wrote:
>
> Hi Hao,
> I have been some issues of this kind also with DC9.62. When i use DC 8.01
> everything works right.
>
> Regards
> Jesus
> De: Hao Wu
> Responder a:
> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
> Para:
> Asunto: [rabbit-semi] Open Sockets
>
>
>
>
>
>
> Hi,
>
> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
> communication centre in this project. UDP client/server, Telnet client, FTP
> server, TFTP client must be implemented.
>
> The system is working but seems a bit clunky. The most annoying problem is
> that the BL2600 occasionally becomes un-ping-able after running a certain
> period. At that time, it's still able to send data out but unable to
> receive. And it can't be restored unless a power cycle.
>
> I suspect it may caused by using out of the socket. I have set both the
> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program is
> not likely to use so many sockets.
>
> If I disable the Telnet task, this problem won't happen any more.
>
> In the Telnet task, I use sock_alive to detect the status of the socket. If
> it returns 0, I consider the Telnet connection being lost, so basically the
> code is like:
>
> while(1)
> {
> VdHitWd(wdID);
> if (sock_alive(&s1) == 0)
> {
> sock_close(&s1);
> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
> buf1size);
> }
> if (sock_alive(&s2) == 0)
> {
> sock_close(&s2);
> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
> buf2size);
> }
> ............
> OSTimeDly(OS_TICKS_PER_SEC);
> }
>
> Is there anything wrong? And is there anyway to know how many sockets are
> being used currently?
>
> Thanks a lot!
>
> Regards,
> Hao
>

On Mon, March 19, 2012 10:08 am, mario_wtbbh said:
> Are you calling tcp_tick(NULL) often enough in your main loop to keep the
> TCP processes working?
>

I will second what Mario said. After a close, it would be
good to call tcp_tick() a few times. A TCP close is three-way
handshake operation :
http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination

With uc/OS, all your sockets must be global vars.
Also, in your thread code, do you actually use the sockets?
Are the sockets used in any other threads? If used in
other threads, you should suspend their usage while the
socket connection is re-established.
take care,
*the other brian
> --- In r..., Jesus Manuel Conejo Sarabia
> wrote:
>>
>> Hi Hao,
>> I have been some issues of this kind also with DC9.62. When i use
>> DC 8.01 everything works right.
>>
>> Regards
>> Jesus
>> De: Hao Wu
>> Responder a:
>> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
>> Para:
>> Asunto: [rabbit-semi] Open Sockets
>>
>> Hi,
>>
>> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
>> communication centre in this project. UDP client/server, Telnet client,
>> FTP
>> server, TFTP client must be implemented.
>>
>> The system is working but seems a bit clunky. The most annoying
>> problem is that the BL2600 occasionally becomes un-ping-able
>> after running a certain period.
>> At that time, it's still able to send data out but unable to
>> receive. And it can't be restored unless a power cycle.
>>
>> I suspect it may caused by using out of the socket. I have set both the
>> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program
>> is not likely to use so many sockets.
>>
>> If I disable the Telnet task, this problem won't happen any more.
>>
>> In the Telnet task, I use sock_alive to detect the status of the
>> socket. If it returns 0, I consider the Telnet connection being
>> lost, so basically the code is like:
>>
>> while(1)
>> {
>> VdHitWd(wdID);
>> if (sock_alive(&s1) == 0)
>> {
>> sock_close(&s1);
>> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
>> buf1size);
>> }
>> if (sock_alive(&s2) == 0)
>> {
>> sock_close(&s2);
>> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
>> buf2size);
>> }
>> ............
>> OSTimeDly(OS_TICKS_PER_SEC);
>> }
>>
>> Is there anything wrong? And is there anyway to know how many sockets
>> are being used currently?
>>
>> Thanks a lot!
>>
>> Regards,
>> Hao
>

Hi guys,

Actually it's a bit complicated.

I called sock_alive() instead of tcp_tick() because different sockets are
created in separate task. I'd like to deal with them separately.

But all the sockets are only used in the task who opened them. i.e. not
used in other tasks.

The telnet sessions are supposed to be always open, in order to sending
commands continuously to get some status data from peer devices. But if the
telnet session is closed / disconnected for some reason. The program must
be able to re-connect it automatically.

The tricky thing is: as the BL2600 has only one Ethernet port, while we
have devices in a different subnet. I'm using telnet cascading like: BL2600
=> DeviceA => DeviceB. When the DeviceB stops responding for some reason, I
close the telnet socket and try re-open it. I think it is where the problem
is. Since the DeviceA is working well, the tcp_extopen() is always
succesful. As sock_close() takes time. It is possible that one socket is
opened again before it's closed properly.

Maybe I set some delay before re-opening a socket? What's your opinion?
Thanks.

Regards,
Hao

On Tue, Mar 20, 2012 at 5:09 AM, wrote:

> **
> On Mon, March 19, 2012 10:08 am, mario_wtbbh said:
> > Are you calling tcp_tick(NULL) often enough in your main loop to keep the
> > TCP processes working?
> > I will second what Mario said. After a close, it would be
> good to call tcp_tick() a few times. A TCP close is three-way
> handshake operation :
>
> http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination
>
> With uc/OS, all your sockets must be global vars.
>
> Also, in your thread code, do you actually use the sockets?
> Are the sockets used in any other threads? If used in
> other threads, you should suspend their usage while the
> socket connection is re-established.
>
> take care,
> *the other brian
> > --- In r..., Jesus Manuel Conejo Sarabia
> > wrote:
> >>
> >> Hi Hao,
> >> I have been some issues of this kind also with DC9.62. When i use
> >> DC 8.01 everything works right.
> >>
> >> Regards
> >> Jesus
> >>
> >>
> >>
> >>
> >> De: Hao Wu
> >> Responder a:
> >> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
> >> Para:
> >> Asunto: [rabbit-semi] Open Sockets
> >>
> >>
> >>
> >> Hi,
> >>
> >> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
> >> communication centre in this project. UDP client/server, Telnet client,
> >> FTP
> >> server, TFTP client must be implemented.
> >>
> >> The system is working but seems a bit clunky. The most annoying
> >> problem is that the BL2600 occasionally becomes un-ping-able
> >> after running a certain period.
> >> At that time, it's still able to send data out but unable to
> >> receive. And it can't be restored unless a power cycle.
> >>
> >> I suspect it may caused by using out of the socket. I have set both the
> >> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program
> >> is not likely to use so many sockets.
> >>
> >> If I disable the Telnet task, this problem won't happen any more.
> >>
> >> In the Telnet task, I use sock_alive to detect the status of the
> >> socket. If it returns 0, I consider the Telnet connection being
> >> lost, so basically the code is like:
> >>
> >> while(1)
> >> {
> >> VdHitWd(wdID);
> >> if (sock_alive(&s1) == 0)
> >> {
> >> sock_close(&s1);
> >> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
> >> buf1size);
> >> }
> >> if (sock_alive(&s2) == 0)
> >> {
> >> sock_close(&s2);
> >> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
> >> buf2size);
> >> }
> >> ............
> >> OSTimeDly(OS_TICKS_PER_SEC);
> >> }
> >>
> >> Is there anything wrong? And is there anyway to know how many sockets
> >> are being used currently?
> >>
> >> Thanks a lot!
> >>
> >> Regards,
> >> Hao
> >>
> >
> >
> >
>
Sockets can take a while to close.
I use this routine; and you must call tcp_tick(sock) while waiting

xmem BOOL TCPClose(void *sock, int TimeOut)
{
unsigned long T1;

sock_close(sock); // close the socket
tout = SEC_TIMER;
while(tcp_tick(sock))
{
if(SEC_TIMER - tout > (unsigned long)TimeOut)
{
sock_abort(sock);
tcp_tick(NULL);
ShowString("Sock Close Timed out\r\n");
break;
}
}

return (tcp_tick(sock) == 0);
}
--- In r..., Hao Wu wrote:
>
> Hi guys,
>
> Actually it's a bit complicated.
>
> I called sock_alive() instead of tcp_tick() because different sockets are
> created in separate task. I'd like to deal with them separately.
>
> But all the sockets are only used in the task who opened them. i.e. not
> used in other tasks.
>
> The telnet sessions are supposed to be always open, in order to sending
> commands continuously to get some status data from peer devices. But if the
> telnet session is closed / disconnected for some reason. The program must
> be able to re-connect it automatically.
>
> The tricky thing is: as the BL2600 has only one Ethernet port, while we
> have devices in a different subnet. I'm using telnet cascading like: BL2600
> => DeviceA => DeviceB. When the DeviceB stops responding for some reason, I
> close the telnet socket and try re-open it. I think it is where the problem
> is. Since the DeviceA is working well, the tcp_extopen() is always
> succesful. As sock_close() takes time. It is possible that one socket is
> opened again before it's closed properly.
>
> Maybe I set some delay before re-opening a socket? What's your opinion?
> Thanks.
>
> Regards,
> Hao
>
> On Tue, Mar 20, 2012 at 5:09 AM, wrote:
>
> > **
> >
> >
> > On Mon, March 19, 2012 10:08 am, mario_wtbbh said:
> > > Are you calling tcp_tick(NULL) often enough in your main loop to keep the
> > > TCP processes working?
> > >
> >
> > I will second what Mario said. After a close, it would be
> > good to call tcp_tick() a few times. A TCP close is three-way
> > handshake operation :
> >
> > http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination
> >
> > With uc/OS, all your sockets must be global vars.
> >
> > Also, in your thread code, do you actually use the sockets?
> > Are the sockets used in any other threads? If used in
> > other threads, you should suspend their usage while the
> > socket connection is re-established.
> >
> > take care,
> > *the other brian
> >
> >
> > > --- In r..., Jesus Manuel Conejo Sarabia
> > > wrote:
> > >>
> > >> Hi Hao,
> > >> I have been some issues of this kind also with DC9.62. When i use
> > >> DC 8.01 everything works right.
> > >>
> > >> Regards
> > >> Jesus
> > >>
> > >>
> > >>
> > >>
> > >> De: Hao Wu
> > >> Responder a:
> > >> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
> > >> Para:
> > >> Asunto: [rabbit-semi] Open Sockets
> > >>
> > >>
> > >>
> > >> Hi,
> > >>
> > >> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
> > >> communication centre in this project. UDP client/server, Telnet client,
> > >> FTP
> > >> server, TFTP client must be implemented.
> > >>
> > >> The system is working but seems a bit clunky. The most annoying
> > >> problem is that the BL2600 occasionally becomes un-ping-able
> > >> after running a certain period.
> > >> At that time, it's still able to send data out but unable to
> > >> receive. And it can't be restored unless a power cycle.
> > >>
> > >> I suspect it may caused by using out of the socket. I have set both the
> > >> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program
> > >> is not likely to use so many sockets.
> > >>
> > >> If I disable the Telnet task, this problem won't happen any more.
> > >>
> > >> In the Telnet task, I use sock_alive to detect the status of the
> > >> socket. If it returns 0, I consider the Telnet connection being
> > >> lost, so basically the code is like:
> > >>
> > >> while(1)
> > >> {
> > >> VdHitWd(wdID);
> > >> if (sock_alive(&s1) == 0)
> > >> {
> > >> sock_close(&s1);
> > >> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
> > >> buf1size);
> > >> }
> > >> if (sock_alive(&s2) == 0)
> > >> {
> > >> sock_close(&s2);
> > >> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
> > >> buf2size);
> > >> }
> > >> ............
> > >> OSTimeDly(OS_TICKS_PER_SEC);
> > >> }
> > >>
> > >> Is there anything wrong? And is there anyway to know how many sockets
> > >> are being used currently?
> > >>
> > >> Thanks a lot!
> > >>
> > >> Regards,
> > >> Hao
> > >>
> > >
> > >
> > >
> >
> >
>

Two things to remember when using TCP/IP and uCOS-II:

1) Use a 4KB stack for any task that calls tcp_tick(), or a function that calls tcp_tick() (like the FTP or HTTP tick functions).

2) Declare all of your sockets as global variables instead of on the stack for a given task or your main(). If you call tcp_tick() for task A, it may need to reference the socket structures for ANY open socket. If one of those sockets happens to be on the stack of task B, tcp_tick() can't access it since task A's stack is in place.

-Tom
On Mar 19, 2012, at 4:11 PM, Hao Wu wrote:

> Hi guys,
>
> Actually it's a bit complicated.
>
> I called sock_alive() instead of tcp_tick() because different sockets are created in separate task. I'd like to deal with them separately.
>
> But all the sockets are only used in the task who opened them. i.e. not used in other tasks.
>
> The telnet sessions are supposed to be always open, in order to sending commands continuously to get some status data from peer devices. But if the telnet session is closed / disconnected for some reason. The program must be able to re-connect it automatically.
>
> The tricky thing is: as the BL2600 has only one Ethernet port, while we have devices in a different subnet. I'm using telnet cascading like: BL2600 => DeviceA => DeviceB. When the DeviceB stops responding for some reason, I close the telnet socket and try re-open it. I think it is where the problem is. Since the DeviceA is working well, the tcp_extopen() is always succesful. As sock_close() takes time. It is possible that one socket is opened again before it's closed properly.
>
> Maybe I set some delay before re-opening a socket? What's your opinion? Thanks.
>
> Regards,
> Hao
> On Tue, Mar 20, 2012 at 5:09 AM, wrote:
>
>
> On Mon, March 19, 2012 10:08 am, mario_wtbbh said:
> > Are you calling tcp_tick(NULL) often enough in your main loop to keep the
> > TCP processes working?
> > I will second what Mario said. After a close, it would be
> good to call tcp_tick() a few times. A TCP close is three-way
> handshake operation :
> http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination
>
> With uc/OS, all your sockets must be global vars.
>
> Also, in your thread code, do you actually use the sockets?
> Are the sockets used in any other threads? If used in
> other threads, you should suspend their usage while the
> socket connection is re-established.
>
> take care,
> *the other brian
> > --- In r..., Jesus Manuel Conejo Sarabia
> > wrote:
> >>
> >> Hi Hao,
> >> I have been some issues of this kind also with DC9.62. When i use
> >> DC 8.01 everything works right.
> >>
> >> Regards
> >> Jesus
> >>
> >>
> >>
> >>
> >> De: Hao Wu
> >> Responder a:
> >> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
> >> Para:
> >> Asunto: [rabbit-semi] Open Sockets
> >>
> >>
> >>
> >> Hi,
> >>
> >> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
> >> communication centre in this project. UDP client/server, Telnet client,
> >> FTP
> >> server, TFTP client must be implemented.
> >>
> >> The system is working but seems a bit clunky. The most annoying
> >> problem is that the BL2600 occasionally becomes un-ping-able
> >> after running a certain period.
> >> At that time, it's still able to send data out but unable to
> >> receive. And it can't be restored unless a power cycle.
> >>
> >> I suspect it may caused by using out of the socket. I have set both the
> >> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program
> >> is not likely to use so many sockets.
> >>
> >> If I disable the Telnet task, this problem won't happen any more.
> >>
> >> In the Telnet task, I use sock_alive to detect the status of the
> >> socket. If it returns 0, I consider the Telnet connection being
> >> lost, so basically the code is like:
> >>
> >> while(1)
> >> {
> >> VdHitWd(wdID);
> >> if (sock_alive(&s1) == 0)
> >> {
> >> sock_close(&s1);
> >> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
> >> buf1size);
> >> }
> >> if (sock_alive(&s2) == 0)
> >> {
> >> sock_close(&s2);
> >> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
> >> buf2size);
> >> }
> >> ............
> >> OSTimeDly(OS_TICKS_PER_SEC);
> >> }
> >>
> >> Is there anything wrong? And is there anyway to know how many sockets
> >> are being used currently?
> >>
> >> Thanks a lot!
> >>
> >> Regards,
> >> Hao
> >>
> >
> >
> > .
>
>
Hi Hao,
tcp_tick() is the base. Call it as quick as you can. What i do to be sure
about the socket closing is:

sock_close(&my_socket);
tcp_tick(&my_socket)==NULL;
MsDelay(50);
tcp_tick(NULL);
MsDelay(50);
tcp_tick(NULL);

..this never fails for me.

Regards
Jesus

De: Hao Wu
Responder a:
Fecha: Tue, 20 Mar 2012 10:11:15 +1100
Para:
Asunto: Re: [rabbit-semi] Re: Open Sockets

Hi guys,

Actually it's a bit complicated.

I called sock_alive() instead of tcp_tick() because different sockets are
created in separate task. I'd like to deal with them separately.

But all the sockets are only used in the task who opened them. i.e. not used
in other tasks.

The telnet sessions are supposed to be always open, in order to sending
commands continuously to get some status data from peer devices. But if the
telnet session is closed / disconnected for some reason. The program must be
able to re-connect it automatically.

The tricky thing is: as the BL2600 has only one Ethernet port, while we have
devices in a different subnet. I'm using telnet cascading like: BL2600 =>
DeviceA => DeviceB. When the DeviceB stops responding for some reason, I
close the telnet socket and try re-open it. I think it is where the problem
is. Since the DeviceA is working well, the tcp_extopen() is always
succesful. As sock_close() takes time. It is possible that one socket is
opened again before it's closed properly.

Maybe I set some delay before re-opening a socket? What's your opinion?
Thanks.

Regards,
Hao

On Tue, Mar 20, 2012 at 5:09 AM, wrote:
>
>
>
>
>
> On Mon, March 19, 2012 10:08 am, mario_wtbbh said:
>> > Are you calling tcp_tick(NULL) often enough in your main loop to keep the
>> > TCP processes working?
>> > I will second what Mario said. After a close, it would be
> good to call tcp_tick() a few times. A TCP close is three-way
> handshake operation :
> http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_terminat
> ion
>
> With uc/OS, all your sockets must be global vars.
>
> Also, in your thread code, do you actually use the sockets?
> Are the sockets used in any other threads? If used in
> other threads, you should suspend their usage while the
> socket connection is re-established.
>
> take care,
> *the other brian
>> > --- In r... ,
>> Jesus Manuel Conejo Sarabia
>> > wrote:
>>> >>
>>> >> Hi Hao,
>>> >> I have been some issues of this kind also with DC9.62. When i use
>>> >> DC 8.01 everything works right.
>>> >>
>>> >> Regards
>>> >> Jesus
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> De: Hao Wu
>>> >> Responder a: >>> >
>>> >> Fecha: Mon, 19 Mar 2012 12:44:08 +1100
>>> >> Para: >>> >
>>> >> Asunto: [rabbit-semi] Open Sockets
>>> >>
>>> >>
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm developing a BL2600 with DC9.62. The BL2600 is designed to be a
>>> >> communication centre in this project. UDP client/server, Telnet client,
>>> >> FTP
>>> >> server, TFTP client must be implemented.
>>> >>
>>> >> The system is working but seems a bit clunky. The most annoying
>>> >> problem is that the BL2600 occasionally becomes un-ping-able
>>> >> after running a certain period.
>>> >> At that time, it's still able to send data out but unable to
>>> >> receive. And it can't be restored unless a power cycle.
>>> >>
>>> >> I suspect it may caused by using out of the socket. I have set both the
>>> >> MAX_TCP_SOCKET_BUFFERS and MAX_UDP_SOCKET_BUFFERS to 30, and my program
>>> >> is not likely to use so many sockets.
>>> >>
>>> >> If I disable the Telnet task, this problem won't happen any more.
>>> >>
>>> >> In the Telnet task, I use sock_alive to detect the status of the
>>> >> socket. If it returns 0, I consider the Telnet connection being
>>> >> lost, so basically the code is like:
>>> >>
>>> >> while(1)
>>> >> {
>>> >> VdHitWd(wdID);
>>> >> if (sock_alive(&s1) == 0)
>>> >> {
>>> >> sock_close(&s1);
>>> >> tcp_extopen(&s1, IF_ANY, 0, ipaddr1, 23, s1_handler, buf1,
>>> >> buf1size);
>>> >> }
>>> >> if (sock_alive(&s2) == 0)
>>> >> {
>>> >> sock_close(&s2);
>>> >> tcp_extopen(&s2, IF_ANY, 0, ipaddr2, 23, s2_handler, buf2,
>>> >> buf2size);
>>> >> }
>>> >> ............
>>> >> OSTimeDly(OS_TICKS_PER_SEC);
>>> >> }
>>> >>
>>> >> Is there anything wrong? And is there anyway to know how many sockets
>>> >> are being used currently?
>>> >>
>>> >> Thanks a lot!
>>> >>
>>> >> Regards,
>>> >> Hao
>>> >>
>> >
>> >
>> >
>
>
>