📄 tcp.h
字号:
/*
* tcp_write - 往连接中写入数据
* - 返回写入的字节数返回0表示俩见没有建立好
*/
void tcp_write( tcp_Socket xdata *s, uchar xdata *dp, int xdata len )
{
int x;
if ( s->state != tcp_StateESTAB )
len = 0;
if ( len > (x = tcp_MaxBufSize - s->datalen) )
len = x;
if ( len > 0 )
{
movmem( dp, s->data + s->datalen, len );
s->datalen += len;
s->unhappy = TRUE;
s->timeout = sock_data_timeout ;
tcp_send( s, __LINE__ );
}
}
int _ip_delay1( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr)
{
int status;
ip_timer_init( s , timeoutseconds );
sock_flush( s );
do
{
if ( sock_dataready( s ))
{
status = 0;
break;
}
kbhit(); /* permit ^c */
if ( !tcp_tick( s ))
{
status = 1;
break;
}
if ( ip_timer_expired( s ))
{
s->tcp.err_msg = "Connection timed out";
sock_close( s );
status = -1;
break;
}
if (fn)
{
if ((status = fn(s)) != 0)
break;
}
} while ( 1 );
if (statusptr)
*statusptr = status;
return( status );
}
int _ip_delay2( sock_type *s, int timeoutseconds, sockfunct_t fn, int *statusptr)
{
int status;
ip_timer_init( s , timeoutseconds );
do
{
/* 这时候用户不会读取得数据的,所以可以清空缓存 */
s->tcp.rdatalen = 0;
kbhit(); /* permit ^c */
if ( !tcp_tick( s ))
{
status = 1;
break;
}
if ( ip_timer_expired( s ))
{
s->tcp.err_msg = "Connection timed out";
sock_abort( s );
status = -1;
break;
}
if (fn)
{
if ((status = fn(s)) != 0)
break;
}
} while ( 1 );
if (statusptr)
*statusptr = status;
return( status );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -