|
创建Socket连接(init):
lrs_startup(257);
lrs_create_socket("socket1","TCP","RemoteHost=denny:10000",LrsLastArg);
发送报文(action):
char *input = lr_eval_string("<chatcontent>");
lrs_save_param_ex("socket1", "user", input, 0, strlen(input), NULL, "param"); //这两句为参数化报文内容,可不用
lr_start_transaction("startsend");
lrs_send("socket1", "buf0", LrsLastArg); //发送报文的关键语句
lrs_receive("socket1", "buf1", LrsLastArg); //此句可注释,不用接收
lr_end_transaction("startsend", LR_AUTO);
关闭连接(end):
lrs_close_socket("socket1");
lrs_cleanup();
data.ws内容:
;WSRData 2 1
send buf0 4
"<param>\n" //此处为报文内容,已被参数化,也可直接写报文内容
recv buf1 * //*表示对服务器端的返回不做验证
"Hello World from Server"
-1
[ 本帖最后由 dennyqiang 于 2009-11-27 00:41 编辑 ] |
|