B
baddy
Unregistered / Unconfirmed
GUEST, unregistred user!
var
str1,str:string;
mstream:tmemorystream;
R,i:longword;
ch_byte:array [1..100] of byte;
temp_byte:array [1..4] of byte absolute R;
begin
mstream:=tmemorystream.create;
stringstream:=tstringstream.create(str);
fillchar(ch_byte,sizeof(ch_byte),0);
fillchar(temp_byte,sizeof(temp_byte),0);
try
R:=htonl(61);
for i:=1 to 4 do
ch_byte:=temp_byte;
R:=htonl(1);
for i:=1 to 4 do
ch_byte[i+4]:=temp_byte;
R:=htonl(source_no);
for i:=1 to 4 do
ch_byte[i+8]:=temp_byte;
str:=FormatDateTime('mmddhhnnss',now());
str_time:=str;
R:=htonl(strtoint(str));
for i:=1 to 4 do
ch_byte[i+12]:=temp_byte;
command_no:=command_no+1;
R:=htonl(command_no);
for i:=1 to 4 do
ch_byte[i+16]:=temp_byte;//完成消息头!
login_type:=1;
R:=htonl(login_type);
ch_byte[21]:=temp_byte[4];
mstream.write(ch_byte,21);
login_name:=chatform.edit2.text;
login_password:=chatform.edit3.text;
if length(login_name)<16 then
login_name:=login_name+copy(strtemp,1,16-length(login_name));
if length(login_password)<16 then
login_password:=login_password+copy(strtemp,1,16-length(login_password));
str1:=login_name+login_password+reserve;
mstream.write(str1[1],40); //
chatform.ClientSocket.Socket.sendbuf(mstream,61);
finally
mstream.Free;
end;
//以上的客户信息能完成整数与字符串连接并发送到服务器端?另,客户机收到的数据总是与发出的数据不一致,
其中服务器端的接收是这样的:
socket.receivebuf(ch_byte,21);
for i:=1 to 4 do
temp_byte:=ch_byte;
mes_len:=ntohl(r);
请大家指出问题所在?!
谢谢!
str1,str:string;
mstream:tmemorystream;
R,i:longword;
ch_byte:array [1..100] of byte;
temp_byte:array [1..4] of byte absolute R;
begin
mstream:=tmemorystream.create;
stringstream:=tstringstream.create(str);
fillchar(ch_byte,sizeof(ch_byte),0);
fillchar(temp_byte,sizeof(temp_byte),0);
try
R:=htonl(61);
for i:=1 to 4 do
ch_byte:=temp_byte;
R:=htonl(1);
for i:=1 to 4 do
ch_byte[i+4]:=temp_byte;
R:=htonl(source_no);
for i:=1 to 4 do
ch_byte[i+8]:=temp_byte;
str:=FormatDateTime('mmddhhnnss',now());
str_time:=str;
R:=htonl(strtoint(str));
for i:=1 to 4 do
ch_byte[i+12]:=temp_byte;
command_no:=command_no+1;
R:=htonl(command_no);
for i:=1 to 4 do
ch_byte[i+16]:=temp_byte;//完成消息头!
login_type:=1;
R:=htonl(login_type);
ch_byte[21]:=temp_byte[4];
mstream.write(ch_byte,21);
login_name:=chatform.edit2.text;
login_password:=chatform.edit3.text;
if length(login_name)<16 then
login_name:=login_name+copy(strtemp,1,16-length(login_name));
if length(login_password)<16 then
login_password:=login_password+copy(strtemp,1,16-length(login_password));
str1:=login_name+login_password+reserve;
mstream.write(str1[1],40); //
chatform.ClientSocket.Socket.sendbuf(mstream,61);
finally
mstream.Free;
end;
//以上的客户信息能完成整数与字符串连接并发送到服务器端?另,客户机收到的数据总是与发出的数据不一致,
其中服务器端的接收是这样的:
socket.receivebuf(ch_byte,21);
for i:=1 to 4 do
temp_byte:=ch_byte;
mes_len:=ntohl(r);
请大家指出问题所在?!
谢谢!