Q
qi_jianzhou
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
TcpClient1: TTcpClient;
TcpServer1: TTcpServer;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
procedure FormCreate(Sender: TObject);
procedure TcpClient1Connect(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to memo2.Lines.Count-1 do begin
tcpClient1.Sendln(memo2.Lines);
end;
end;
procedure TForm1.TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
var
s:string;
begin
s:=clientSocket.Receiveln;
while s<>'' do begin
memo1.Lines.Add(s);
s:=clientSocket.Receiveln;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
tcpServer1.Active:=true;
tcpClient1.Active:=true;
//tcpClient1.sen
end;
procedure TForm1.TcpClient1Connect(Sender: TObject);
begin
showmessage('ok');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
tcpClient1.Connect;
end;
end.
点 连接的按纽就是连不到 tcpServer ,我看了看 demos 里的例子,我不想用线程来做,可是这样又连不到 TcpServer ,大家帮我看看是哪里错了
谢谢了
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Sockets, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
TcpClient1: TTcpClient;
TcpServer1: TTcpServer;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
procedure FormCreate(Sender: TObject);
procedure TcpClient1Connect(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to memo2.Lines.Count-1 do begin
tcpClient1.Sendln(memo2.Lines);
end;
end;
procedure TForm1.TcpServer1Accept(Sender: TObject;
ClientSocket: TCustomIpClient);
var
s:string;
begin
s:=clientSocket.Receiveln;
while s<>'' do begin
memo1.Lines.Add(s);
s:=clientSocket.Receiveln;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
tcpServer1.Active:=true;
tcpClient1.Active:=true;
//tcpClient1.sen
end;
procedure TForm1.TcpClient1Connect(Sender: TObject);
begin
showmessage('ok');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
tcpClient1.Connect;
end;
end.
点 连接的按纽就是连不到 tcpServer ,我看了看 demos 里的例子,我不想用线程来做,可是这样又连不到 TcpServer ,大家帮我看看是哪里错了
谢谢了