#include "lrs.h"
/*
*作者:郭振华
*功能:与机器人玩斗地主,必须受到指定长度的值才能进行下一步,否则就退出
*日期:2011-12-30
*/
Action()
{
int rc;
char *ActualBuffer;
rc=lrs_create_socket("socket0", "TCP", "RemoteHost=***********(服务器地址和端口)", LrsLastArg);
if(rc!=0){
lr_error_message("连接建立失败!");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf0",LrsLastArg);
lrs_receive("socket0", "buf1", LrsLastArg);
lrs_receive("socket0", "buf2", LrsLastArg);
lrs_receive("socket0", "buf3", LrsLastArg);
lrs_get_buffer_by_name("buf3", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf3接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf4",LrsLastArg);
lrs_receive("socket0", "buf5", LrsLastArg);
lrs_get_buffer_by_name("buf5", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=16) {
lr_error_message("buf5接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf6",LrsLastArg);
lrs_receive("socket0", "buf7", LrsLastArg);
lrs_get_buffer_by_name("buf7", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=32) {
lr_error_message("buf7接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf8",LrsLastArg);//开始出牌
lrs_receive("socket0", "buf9", LrsLastArg);
lrs_receive("socket0", "buf10", LrsLastArg);
lrs_receive("socket0", "buf11", LrsLastArg);
lrs_get_buffer_by_name("buf11", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf11接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf12",LrsLastArg);
lrs_receive("socket0", "buf13", LrsLastArg);
lrs_get_buffer_by_name("buf13", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=16) {
lr_error_message("buf13接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf14",LrsLastArg);
lrs_receive("socket0", "buf15", LrsLastArg);
lrs_receive("socket0", "buf16", LrsLastArg);
lrs_receive("socket0", "buf17", LrsLastArg);
lrs_get_buffer_by_name("buf17", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=26) {
lr_error_message("buf17接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf18",LrsLastArg);
lrs_receive("socket0", "buf19", LrsLastArg);
lrs_receive("socket0", "buf20", LrsLastArg);
lrs_receive("socket0", "buf21", LrsLastArg);
lrs_get_buffer_by_name("buf21", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=14) {
lr_error_message("buf21接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf22",LrsLastArg);
lrs_receive("socket0", "buf23", LrsLastArg);
lrs_receive("socket0", "buf24", LrsLastArg);
lrs_receive("socket0", "buf25", LrsLastArg);
lrs_get_buffer_by_name("buf25", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=27) {
lr_error_message("buf25接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf26",LrsLastArg);
lrs_receive("socket0", "buf27", LrsLastArg);
lrs_receive("socket0", "buf28", LrsLastArg);
lrs_receive("socket0", "buf29", LrsLastArg);
lrs_get_buffer_by_name("buf29", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=17) {
lr_error_message("buf29接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf30",LrsLastArg);
lrs_receive("socket0", "buf31", LrsLastArg);
lrs_receive("socket0", "buf32", LrsLastArg);
lrs_receive("socket0", "buf33", LrsLastArg);
lrs_get_buffer_by_name("buf33", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf33接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf34",LrsLastArg);
lrs_receive("socket0", "buf35", LrsLastArg);
lrs_receive("socket0", "buf36", LrsLastArg);
lrs_receive("socket0", "buf37", LrsLastArg);
lrs_get_buffer_by_name("buf37", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf37接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf38",LrsLastArg);
lrs_receive("socket0", "buf39", LrsLastArg);
lrs_receive("socket0", "buf40", LrsLastArg);
lrs_receive("socket0", "buf41", LrsLastArg);
lrs_get_buffer_by_name("buf41", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=21) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf42",LrsLastArg);
lrs_receive("socket0", "buf43", LrsLastArg);
lrs_receive("socket0", "buf44", LrsLastArg);
lrs_receive("socket0", "buf45", LrsLastArg);
lrs_get_buffer_by_name("buf45", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf46",LrsLastArg);
lrs_receive("socket0", "buf47", LrsLastArg);
lrs_receive("socket0", "buf48", LrsLastArg);
lrs_receive("socket0", "buf49", LrsLastArg);
lrs_get_buffer_by_name("buf49", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=23) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf50",LrsLastArg);
lrs_receive("socket0", "buf51", LrsLastArg);
lrs_receive("socket0", "buf52", LrsLastArg);
lrs_get_buffer_by_name("buf52", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=63) {
lr_error_message("buf52接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lr_end_transaction("开始", LR_AUTO);
lrs_close_socket("socket0");
return 0;
}
/*
*作者:郭振华
*功能:与机器人玩斗地主,必须受到指定长度的值才能进行下一步,否则就退出
*日期:2011-12-30
*/
Action()
{
int rc;
char *ActualBuffer;
int NumberOfBytes;
lr_start_transaction("开始");rc=lrs_create_socket("socket0", "TCP", "RemoteHost=***********(服务器地址和端口)", LrsLastArg);
if(rc!=0){
lr_error_message("连接建立失败!");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf0",LrsLastArg);
lrs_set_receive_option(EndMarker, StringTerminator, "\r");
lrs_receive("socket0", "buf1", LrsLastArg);
lrs_receive("socket0", "buf2", LrsLastArg);
lrs_receive("socket0", "buf3", LrsLastArg);
lrs_get_buffer_by_name("buf3", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf3接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf4",LrsLastArg);
lrs_receive("socket0", "buf5", LrsLastArg);
lrs_get_buffer_by_name("buf5", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=16) {
lr_error_message("buf5接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf6",LrsLastArg);
lrs_receive("socket0", "buf7", LrsLastArg);
lrs_get_buffer_by_name("buf7", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=32) {
lr_error_message("buf7接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf8",LrsLastArg);//开始出牌
lrs_receive("socket0", "buf9", LrsLastArg);
lrs_receive("socket0", "buf10", LrsLastArg);
lrs_receive("socket0", "buf11", LrsLastArg);
lrs_get_buffer_by_name("buf11", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf11接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf12",LrsLastArg);
lrs_receive("socket0", "buf13", LrsLastArg);
lrs_get_buffer_by_name("buf13", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=16) {
lr_error_message("buf13接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf14",LrsLastArg);
lrs_receive("socket0", "buf15", LrsLastArg);
lrs_receive("socket0", "buf16", LrsLastArg);
lrs_receive("socket0", "buf17", LrsLastArg);
lrs_get_buffer_by_name("buf17", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=26) {
lr_error_message("buf17接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf18",LrsLastArg);
lrs_receive("socket0", "buf19", LrsLastArg);
lrs_receive("socket0", "buf20", LrsLastArg);
lrs_receive("socket0", "buf21", LrsLastArg);
lrs_get_buffer_by_name("buf21", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=14) {
lr_error_message("buf21接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf22",LrsLastArg);
lrs_receive("socket0", "buf23", LrsLastArg);
lrs_receive("socket0", "buf24", LrsLastArg);
lrs_receive("socket0", "buf25", LrsLastArg);
lrs_get_buffer_by_name("buf25", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=27) {
lr_error_message("buf25接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf26",LrsLastArg);
lrs_receive("socket0", "buf27", LrsLastArg);
lrs_receive("socket0", "buf28", LrsLastArg);
lrs_receive("socket0", "buf29", LrsLastArg);
lrs_get_buffer_by_name("buf29", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=17) {
lr_error_message("buf29接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf30",LrsLastArg);
lrs_receive("socket0", "buf31", LrsLastArg);
lrs_receive("socket0", "buf32", LrsLastArg);
lrs_receive("socket0", "buf33", LrsLastArg);
lrs_get_buffer_by_name("buf33", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf33接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf34",LrsLastArg);
lrs_receive("socket0", "buf35", LrsLastArg);
lrs_receive("socket0", "buf36", LrsLastArg);
lrs_receive("socket0", "buf37", LrsLastArg);
lrs_get_buffer_by_name("buf37", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf37接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf38",LrsLastArg);
lrs_receive("socket0", "buf39", LrsLastArg);
lrs_receive("socket0", "buf40", LrsLastArg);
lrs_receive("socket0", "buf41", LrsLastArg);
lrs_get_buffer_by_name("buf41", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=21) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf42",LrsLastArg);
lrs_receive("socket0", "buf43", LrsLastArg);
lrs_receive("socket0", "buf44", LrsLastArg);
lrs_receive("socket0", "buf45", LrsLastArg);
lrs_get_buffer_by_name("buf45", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=11) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf46",LrsLastArg);
lrs_receive("socket0", "buf47", LrsLastArg);
lrs_receive("socket0", "buf48", LrsLastArg);
lrs_receive("socket0", "buf49", LrsLastArg);
lrs_get_buffer_by_name("buf49", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=23) {
lr_error_message("buf41接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lrs_send("socket0","buf50",LrsLastArg);
lrs_receive("socket0", "buf51", LrsLastArg);
lrs_receive("socket0", "buf52", LrsLastArg);
lrs_get_buffer_by_name("buf52", &ActualBuffer, &NumberOfBytes);
if (NumberOfBytes!=63) {
lr_error_message("buf52接受的数据不正确");
lrs_close_socket("socket0");
lr_abort();
}
lr_end_transaction("开始", LR_AUTO);
lrs_close_socket("socket0");
return 0;
}