I
insert2003
Unregistered / Unconfirmed
GUEST, unregistred user!
服务端用VC写好的,完全正确,无需我处理!
const
d_MaxDetailNum = 100;
flagLogin = $80;
flagQueryInfo = $82;
flagChangePassword = $83;
flagQueryAmount = $85;
flagQueryDetail = $86;
flagCharge = $89;
d_LogName_Len = 20;
d_LogPassword_Len = 10;
d_CardNo_Len = 20;
d_Phone_Len = 7;
d_Name_Len = 30;
d_IDCardNo_Len = 18;
d_Address_Len = 40;
d_LinkTel_Len = 30;
d_Date_Len = 8;
d_Time_Len = 19;
d_DealNo_Len = 14;
d_Error_Ok = $00; //
d_Error_CommError = $01; // 通信错误
d_Error_InvalidName = $02; // 登录名错误
d_Error_PasswordError = $03; // 密码错误
d_Error_AcccountFreeze = $04; // 帐户冻结
d_Error_InvalidPhone = $05; // 非法电话
d_Error_SystemError = $06; // 系统
d_Error_NoData = $07; // 没有数据
d_Error_OtherError = $ff; // 其它错误
type
structClientPackHead = Record // 数据包
uPackLength :Longint;
uFlag :Longint;
cRequire :char;
cAnswer :char;
cCRC :array[0..5] of char ;
end;
structClientLogin = packed Record //登录数据
cLogNamm :array[0..d_LogName_Len] of char;
cLogPassword :array[0..d_LogPassword_Len] of char;
end;
structClientChangePassword = Record //修改密码
cOldPassword :array[0..d_LogPassword_Len] of char;
cNewPassword :array[0..d_LogPassword_Len] of char;
end;
structClientQueryInfo = Record // 查询机主资料
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientQueryInfoAnswer = Record // 查询机主资料应答
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
cName :array[0..d_Name_Len] of char;
cIDCardNo :array[0..d_IDCardNo_Len] of char;
cAddress :array[0..d_Address_Len] of char;
cLinkTel :array[0..d_LinkTel_Len] of char;
end;
structClientCharge = Record // 充值
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
uAmount :Integer;
end;
structClientQueryAmount = Record // 查询充值金额
cStartDate :array[0..d_Date_Len] of char;
cEndDate :array[0..d_Date_Len] of char;
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientQueryAmountAnswer = Record // 查询充值金额返回
uNum :Integer ;
uAmount :Integer;
end;
structClientQueryDetail = Record // 查询充值明细
cStartDate :array[0..d_Date_Len] of char;
cEndDate :array[0..d_Date_Len] of char;
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientChargeDetail = Record // 询充值金额返回
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
uAmount :Integer;
cTime :array[0..d_Time_Len] of char;
cDealNo :array[0..d_DealNo_Len] of char;
end;
structClientQueryDetailAnswer = Record // 查询充值明细返回
uDetailNum :Integer;
ChargeDetail :array[0..d_MaxDetailNum-1] of structClientChargeDetail;
end;
structClientPack = packed Record // 数据包
PackHead :structClientPackHead; //包头
case Integer of
1 Login :structClientLogin; // 登录数据
2 ChangePassword :structClientChangePassword; // 修改密码
3 QueryInfo :structClientQueryInfo; // 查询机主资料
4 QueryInfoAnswer :structClientQueryInfoAnswer; // 查询机主资料应答
5 Charge :structClientCharge; // 充值
6 QueryAmount :structClientQueryAmount; // 查询充值金额
7 QueryDetail :structClientQueryDetail; // 查询充值金额返回
8 QueryDetailAnswer :structClientQueryDetailAnswer; // 查询充值明细返回
end;
问题一:这样赋值得是否正确:
strpcopy(loginclinet.Login.cLogNamm,trim(edit1.Text));
strpcopy(loginclinet.Login.cLogPassword,trim(edit2.Text));
loginclinet.PackHead.uPackLength :=sizeof(structClientPack);
loginclinet.PackHead.uFlag := flagLogin;
loginclinet.PackHead.cRequire :='';
loginclinet.PackHead.cAnswer :='';
问题二:这样发送怎么不行:
var
loginclinet : structClientPack;
clientsocket1.Socket.SendBuf(loginclinet,sizeof(structClientPack));
问题三:怎么接收服务端发过来的数据,服务端定义了现客户端一至的记录类型。
是否用此socket.ReceiveBuf()接收,请问此socket.ReceiveBuf()里面的参数应该怎么写!
const
d_MaxDetailNum = 100;
flagLogin = $80;
flagQueryInfo = $82;
flagChangePassword = $83;
flagQueryAmount = $85;
flagQueryDetail = $86;
flagCharge = $89;
d_LogName_Len = 20;
d_LogPassword_Len = 10;
d_CardNo_Len = 20;
d_Phone_Len = 7;
d_Name_Len = 30;
d_IDCardNo_Len = 18;
d_Address_Len = 40;
d_LinkTel_Len = 30;
d_Date_Len = 8;
d_Time_Len = 19;
d_DealNo_Len = 14;
d_Error_Ok = $00; //
d_Error_CommError = $01; // 通信错误
d_Error_InvalidName = $02; // 登录名错误
d_Error_PasswordError = $03; // 密码错误
d_Error_AcccountFreeze = $04; // 帐户冻结
d_Error_InvalidPhone = $05; // 非法电话
d_Error_SystemError = $06; // 系统
d_Error_NoData = $07; // 没有数据
d_Error_OtherError = $ff; // 其它错误
type
structClientPackHead = Record // 数据包
uPackLength :Longint;
uFlag :Longint;
cRequire :char;
cAnswer :char;
cCRC :array[0..5] of char ;
end;
structClientLogin = packed Record //登录数据
cLogNamm :array[0..d_LogName_Len] of char;
cLogPassword :array[0..d_LogPassword_Len] of char;
end;
structClientChangePassword = Record //修改密码
cOldPassword :array[0..d_LogPassword_Len] of char;
cNewPassword :array[0..d_LogPassword_Len] of char;
end;
structClientQueryInfo = Record // 查询机主资料
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientQueryInfoAnswer = Record // 查询机主资料应答
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
cName :array[0..d_Name_Len] of char;
cIDCardNo :array[0..d_IDCardNo_Len] of char;
cAddress :array[0..d_Address_Len] of char;
cLinkTel :array[0..d_LinkTel_Len] of char;
end;
structClientCharge = Record // 充值
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
uAmount :Integer;
end;
structClientQueryAmount = Record // 查询充值金额
cStartDate :array[0..d_Date_Len] of char;
cEndDate :array[0..d_Date_Len] of char;
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientQueryAmountAnswer = Record // 查询充值金额返回
uNum :Integer ;
uAmount :Integer;
end;
structClientQueryDetail = Record // 查询充值明细
cStartDate :array[0..d_Date_Len] of char;
cEndDate :array[0..d_Date_Len] of char;
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
end;
structClientChargeDetail = Record // 询充值金额返回
cPhone :array[0..d_Phone_Len] of char;
cCardNo :array[0..d_CardNo_Len] of char;
uAmount :Integer;
cTime :array[0..d_Time_Len] of char;
cDealNo :array[0..d_DealNo_Len] of char;
end;
structClientQueryDetailAnswer = Record // 查询充值明细返回
uDetailNum :Integer;
ChargeDetail :array[0..d_MaxDetailNum-1] of structClientChargeDetail;
end;
structClientPack = packed Record // 数据包
PackHead :structClientPackHead; //包头
case Integer of
1 Login :structClientLogin; // 登录数据
2 ChangePassword :structClientChangePassword; // 修改密码
3 QueryInfo :structClientQueryInfo; // 查询机主资料
4 QueryInfoAnswer :structClientQueryInfoAnswer; // 查询机主资料应答
5 Charge :structClientCharge; // 充值
6 QueryAmount :structClientQueryAmount; // 查询充值金额
7 QueryDetail :structClientQueryDetail; // 查询充值金额返回
8 QueryDetailAnswer :structClientQueryDetailAnswer; // 查询充值明细返回
end;
问题一:这样赋值得是否正确:
strpcopy(loginclinet.Login.cLogNamm,trim(edit1.Text));
strpcopy(loginclinet.Login.cLogPassword,trim(edit2.Text));
loginclinet.PackHead.uPackLength :=sizeof(structClientPack);
loginclinet.PackHead.uFlag := flagLogin;
loginclinet.PackHead.cRequire :='';
loginclinet.PackHead.cAnswer :='';
问题二:这样发送怎么不行:
var
loginclinet : structClientPack;
clientsocket1.Socket.SendBuf(loginclinet,sizeof(structClientPack));
问题三:怎么接收服务端发过来的数据,服务端定义了现客户端一至的记录类型。
是否用此socket.ReceiveBuf()接收,请问此socket.ReceiveBuf()里面的参数应该怎么写!