View previous topic :: View next topic |
Author |
Message |
DaeHyun Guest
|
Microchip TCP/IP stack problem for TCP |
Posted: Fri Oct 27, 2006 4:06 am |
|
|
Hi, i'm using stack version 3.75 and CCSC.
IP/ARP/ICMP is working well.
For TCP, all data can be received well, but data can't be sent !!
after debugging, i found the source to make problem.
that is,
Code: |
BOOL TCPIsPutReady(TCP_SOCKET s)
{
if(TCB.RemoteWindow == 0) <<--- always true
return FALSE;
if ( TCB.TxBuffer == INVALID_BUFFER )
return IPIsTxReady(FALSE);
else
return TCB.Flags.bIsPutReady;
}
|
As you can see red words, IF statement is always true..
How can i solve this problem..?? Have any ideas ??
And the main procedure that i was coded is as follows,
--------------------------------------------------------------------------------
Code: |
Int8 telnetdBuff[TELNETD_BUFF_LEN];
Int8 telnetdBuffHeadPtr = 0;
Int8 telnetdBuffTailPtr = 0;
SM_TELNETD smTelnetd = SM_TELNETD_IDLE;
void TELNETD_Init (void)
{
telnetd_socket = TCPListen (TELNET_PORT);
}
void TELNETD_Task (void)
{
BOOL bContinue = FALSE;
if ( !TCPIsConnected(telnetd_socket) ) // [b]<<---- Check Connection [/b]
{
smTelnetd = SM_TELNETD_IDLE;
return;
}
do {
switch (smTelnetd)
{
case SM_TELNETD_IDLE:
smTelnetd = SM_TELNETD_MAIN;
case SM_TELNETD_MAIN:
TELNETD_Process ();
break;
case SM_TELNETD_DISCONNECT:
if(TCPIsPutReady (telnetd_socket))
{
TCPDisconnect (telnetd_socket);
smTelnetd = SM_TELNETD_DISCONNECT_WAIT;
}
break;
}
}
while (bContinue);
}
void TELNETD_Process (void)
{
Int8 length = 0;
if (TCPIsGetReady(telnetd_socket))
{
while (length <TELNETD_BUFF_LEN>= TELNETD_BUFF_LEN)
{
telnetdBuffHeadPtr = 0;
}
}
TCPDiscard(telnetd_socket);
}
/* echo */
if(TCPIsPutReady (telnetd_socket)) // <<Always>= TELNETD_BUFF_LEN)
{
telnetdBuffTailPtr = 0;
}
}
TCPFlush (telnetd_socket);
}
}
|
--------------------------------------------------------------------------------
This is simple echo program with TCP. As above, all data sent from server has been received in the function
TELNETD_Process. But cannot send.
Is there any bugs? if the cause of this problem is window size, how can i solve ?
[/code] |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Oct 27, 2006 4:35 am |
|
|
It looks like something went wrong with the initial connection setup. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Fri Oct 27, 2006 10:39 am |
|
|
The remotes available window size is updated in each received packet. If the remote application is not processing fast enough the window should narrow and eventually close. The PIC should respect the remote window size and not try to overflow it with a transmitted packet. The window size is basically a flow control protocol it shouldn't remain at zero if the socket is open and functioning. Given processing resources the remote application should be consuming sent packets and opening the window. |
|
|
|