Author Topic: TCP send problem  (Read 21596 times)

Offline kno

  • Newbie
  • *
  • Posts: 1
    • View Profile
TCP send problem
« on: May 27, 2010, 11:51:59 PM »

Here is my problem. I can send a tcp data once at each command like this,
 
void cmd_run(void){       
send_nack("first\n");       
tcp_send_buffer;      } 
 
void cmd_run1(void){
send_nack("EXIT\n");
tcp_send_buffer;        }
 
Both run and run1 are working fine, however if I try like this
 
 
void cmd_run(void){
         send_nack("first\n");
         tcp_send_buffer;
         send_nack("EXIT\n");
         tcp_send_buffer;
         }
 
 
It's not working. It freezes after display "first". You guys have any idea? Thanks in advance.
 
Here is a tcp_send_buffer. It's from the OpenTCP example files.
 
 
void tcp_send_buffer(void)
{
UINT32 len;
while(tcp_checksend(tcp_soch) < 0);     
for(len=0;
    {
net_buf[TCP_APP_OFFSET+len] = udp_tcp_buf[len];
if(udp_tcp_buf[len++] == '\n')
   break;
}
 
if(tcp_send(tcp_soch, &net_buf[TCP_APP_OFFSET], NETWORK_TX_BUFFER_SIZE - TCP_APP_OFFSET, len) == len)
   {
DEBUGOUT("TCP: bytes reply sent!\r\n");
}
else
{
    DEBUGOUT("TCP: error occured while trying to send data!\r\n");
}
}

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: TCP send problem
« Reply #1 on: May 28, 2010, 01:10:46 AM »
Hi

I would check this thread for full details of using TCP: http://www.utasker.com/forum/index.php?topic=25.0

There are two methods - simple TCP sockets and buffered TCP sockets. When using simple TCP socket it is important to wait for an ACK before sending a second frame, otherwise there will be sequence number errors. Buffered TCP handles this but needs more memory (critical on NE64!)

Regards

Mark