web_set_sockets_option设置求助(解决no buffer space available问题)
各位大神,执行sockets协议脚本时,总是报no buffer spaceavailable的错,上网查了下解决方案,结合本论坛另外一个帖子“web_set_sockets_option("SHUTDOWN","ABRUPT");执行报错”,好像说是需要添加下面两句话:web_set_sockets_option("SHUTDOWN_MODE","ABRUPT");
web_set_sockets_option("CLOSE_KEEPALIVE_CONNECTIONS","1");
在自己的脚本中添加后,脚本代码如下
#include "lrs.h"
Action()
{
int web_set_sockets_option("SHUTDOWN_MODE","ABRUPT");
//发送报文部分
char toKmc = "\0";
char toKmc1 = "1234\0";
//接收报文部分
char *valBufRecv; //记录接收到的数据包
int lenBufRecv = 0; //记录接收数据包的长度
char *posRespCode;
char valRespCode="\0";
memset( valRespCode, 0, 3);
strcat( toKmc, toKmc1);
lr_start_transaction("1");
ErrCode = lrs_create_socket( "socket0", "TCP", "LocalHost=0", "RemoteHost=192.168.1.1:80", LrsLastArg);
if ( ErrCode != 0 )
{
lr_error_message("Create Socket failed!");
lr_end_transaction( "1", LR_FAIL);
return 0;
}
lrs_set_send_buffer( "socket0", (char *)toKmc, strlen(toKmc) );
lrs_length_send( "socket0", "buf0", 0, LrsLastArg);
lrs_set_recv_timeout( 10, 0);
lrs_set_recv_timeout2( 0.01, 0);
lrs_receive( "socket0", "buf1", LrsLastArg);
lrs_get_last_received_buffer( "socket0", &valBufRecv, &lenBufRecv);
if ( lenBufRecv == 0 )
{
lr_error_message( "No Received Data!" );
ErrCode = lrs_close_socket( "socket0");
if ( ErrCode != 0 )
{
lr_error_message("Close Socket failed!");
lr_end_transaction( "1", LR_FAIL);
return 0;
}
lr_end_transaction( "1", LR_FAIL);
}
else
{
posRespCode = (char *) strstr( valBufRecv, "<RespCode>");
strncpy( valRespCode, posRespCode+10, 2);
if ( strcmp(valRespCode,"S") == 0)
{
lr_end_transaction( "1", LR_PASS);
}
else
{
lr_error_message( "RespCode is %s", valRespCode);
lr_end_transaction( "1", LR_FAIL);
}
lenBufRecv = 0;
lrs_free_buffer( valBufRecv);
ErrCode = lrs_close_socket( "socket0");
if ( ErrCode != 0 )
{
lr_error_message("Close Socket failed!");
return 0;
}
}
web_set_sockets_option("CLOSE_KEEPALIVE_CONNECTIONS","1");
return 0;
}
执行之后还是报错,报错如下
Action.c (17): syntax error; found "SHUTDOWN_MODE" expecting `)'
Action.c (17): skipping "SHUTDOWN_MODE" `,' "ABRUPT"
e:\\boeing\317\265\315\263\274\334\271\271\323\305\273\257\\uep\327\250\317\356\262\342\312\324\\calccdserv\\\\combined_CalCCDServ.c (4): 2 errors, not writing pre_cci.ci
哪位大神能帮忙看看如何解决,多谢! 上来直接包语法错误了 jingzizx 发表于 2017-6-8 23:30
上来直接包语法错误了
可是怎么解决呢
页:
[1]