This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
大家好,我用的是TMS320 674X的芯片,仿真软件为CCS_v5,现在我想用NDK里面的和TCP有关的程序来实现DSP和PC的数据传输,用DaemonNew 回调经过改写过后的 dtask_tcp_echo函数向PC机进行发送数据,里面的send函数是面向连接的。现在我想向PC发4M字节的数,我的和发送数据部分有关的程序 如下:
int dtask_tcp_echo( SOCKET s, UINT32 unused )
{
struct timeval to;
int i;
(void)unused;
// Configure our socket timeout to be 5 seconds
to.tv_sec = 5;
to.tv_usec = 0;
setsockopt( s, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof( to ) );
setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, &to, sizeof( to ) );
i = 1;
setsockopt( s, IPPROTO_TCP, TCP_NOPUSH, &i, 4 );
int count = 0,j;
int back = 1024;
for(;;)
{
i = (int)recv( s, (void **)recv_buffer, sizeof(recv_buffer), 0);
// If we read data, start sending until finish
if(i > 0 )
{
while(1)
{
for(j=0; j<2000; j++) {}
if(send( s, (void*)xmit_buffer, 2*LEN, 0 ) > 0);
{
count++;
}
if(count > back)
{
break;
}
}
// if finished sending wait for next time
Semaphore_post(sem);
}
// If the connection got an error or disconnect, close
else
break;
}
fdClose( s );
// Return "0" since we closed the socket
return(0);
}
recv_buffer 用来接收来自PC端的握手信号,xmit_buffer里面存着待发送的4M字节的数据。
问题如下:
1. dtask_tcp_echo用的是不是TCP协议?
2.send函数里面有关于发送buffer的长度(2*LEN)最大只能设置1024字节,为什么设置大一点就发送不了数据?
3.现在我在PC端运行接收程序,发送端每次发送1024字节的数,多次发送,为什么发送小于8次时PC能正确接收到数据,而多于8次时就接收不到数据?
4.我在每次发送数据之前加了延迟程序 for(j=0; j<2000; j++) { },这次能将数据发送到PC机上,可是速度太慢,4M字节的数据用了一分钟才发完。 我试图通过减小延迟时间来提速,但是延迟一减小,数据又发送不出去了?
请问各位大神,这个问题该怎么解决啊?希望各位不吝赐教!