一个简单的关于网络聊天程序的问题,我是新手请各位大哥帮忙。(0分)

  • 主题发起人 主题发起人 e_gy
  • 开始时间 开始时间
E

e_gy

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用了 Tserversock 和 Tclientsicket来构建简单的点对点程序,可是编译以后发现
当字输入的稍微快一点,对方的屏幕就会乱,很多都是复制的文字,请各位大哥帮忙指教
一下小弟:
procedure TForm9.ToolButton1Click(Sender: TObject);
begin
serversocket1.Active:=false;
clientsocket1.Address:=flatedit1.Text;
clientsocket1.Open;
end;
procedure TForm9.FormCreate(Sender: TObject);
begin
statusbar1.Font.Color:=clRed;
statusbar1.Panels[0].Text:='服务端口已打开目前正在监听中……';
flatedit1.Clear;
serversocket1.Open;
end;
procedure TForm9.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
flatmemo1.Text:=socket.ReceiveText;
end;
procedure TForm9.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
flatmemo1.Text:=socket.ReceiveText;
end;
procedure TForm9.FlatMemo2Change(Sender: TObject);
begin
if serversocket1.Active=true then
serversocket1.Socket.Connections[0].SendText(flatmemo2.Text)
else
clientsocket1.Socket.SendText(flatmemo2.Text)
end;
procedure TForm9.ToolButton2Click(Sender: TObject);
begin
serversocket1.Close;
clientsocket1.Close;
close;
end;
//下面是现实连接状态的代码
procedure TForm9.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Font.Color:=clblack;
statusbar1.Panels[0].Text:='连接成功';
end;
procedure TForm9.ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Font.Color:=clblack;
statusbar1.Panels[0].Text:='正在与'+flatedit1.Text;
end;
procedure TForm9.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Font.Color:=clblack;
statusbar1.Panels[0].Text:='连接成功';
end;
procedure TForm9.ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Font.Color:=clRed;
statusbar1.Panels[0].Text:='连接已断开';

end;

procedure TForm9.ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
statusbar1.Color:=clRed;
statusbar1.Panels[0].Text:='连接已断开';
end;
end.
另外,我使用了改变字体颜色,可是却实现不了,我是新手,程序很简单不要见笑。
 
后退
顶部