ss:TServerSocket for jj:=0 to frm_server.ss.Socket.ActiveConnections-1 do
begin
if (ss.Socket.Connections[jj].RemoteAddress=client_ip) and
(ss.Socket.Connections[jj].RemotePort=client_port) then
begin
ss.Socket.Connections[jj].SendText(mystr);
sc:='成功发送'+client_ip+'端口'+IntToStr(client_port);
sc:=sc+'('+Trim(stime)+'):';
sc:=Trim(sc)+Trim(mystr);
mmo_info.Lines.Add(sc);
end;
end;
为什么用SENDTEXT发过去的串,客户端收到的有时是乱码?用SEDNBUF有时也是乱码?
请高手指点,代码哪错了?该怎样改?谢谢!
begin
if (ss.Socket.Connections[jj].RemoteAddress=client_ip) and
(ss.Socket.Connections[jj].RemotePort=client_port) then
begin
ss.Socket.Connections[jj].SendText(mystr);
sc:='成功发送'+client_ip+'端口'+IntToStr(client_port);
sc:=sc+'('+Trim(stime)+'):';
sc:=Trim(sc)+Trim(mystr);
mmo_info.Lines.Add(sc);
end;
end;
为什么用SENDTEXT发过去的串,客户端收到的有时是乱码?用SEDNBUF有时也是乱码?
请高手指点,代码哪错了?该怎样改?谢谢!
或者应该写在ClientRead中procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
if Socket.RemoteHost='' then Socket.SendText('ok');
end;