首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

*哪位高手有IdTCPClient和IdTCPServer相互传递消息的例子

2012-02-14 
****谁有IdTCPClient和IdTCPServer相互传递消息的例子?我需要一个简单的例子:IdTCPClient传消息到Id

****谁有IdTCPClient和IdTCPServer相互传递消息的例子?
我需要一个简单的例子:
  IdTCPClient   ==>   传消息到==>   IdTCPServer
  IdTCPServer   ==>   传消息到==>   IdTCPClient

[解决办法]
//简单些一个,具体实现的时候就不能这么简单了。。。
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
self.IdTCPServer1.DefaultPort:=88888;
self.IdTCPServer1.Active:=true;

self.IdTCPClient1.Host:= '127.0.0.1 ';
self.IdTCPClient1.Port:=88888;
try
self.IdTCPClient1.Connect( 5000 );
self.IdTCPClient1.Write( 'aaaaa ' );
showmessage( self.IdTCPClient1.ReadLn() );
self.IdTCPClient1.Disconnect;
except
end;

end;

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
with AThread.Connection do
begin
if ReadLn = 'aaaaa ' then
begin
Write( 'hello world ' );
end;
end;
end;
[解决办法]
http://www.2ccc.com/article.asp?articleid=3894
[解决办法]
\Program Files\Borland\Delphi\Demos\Indy\BasicClientServer\
\Program Files\Borland\Delphi6\Demos\Internet\Chat\

[解决办法]
//简单些一个,具体实现的时候就不能这么简单了。。。
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
self.IdTCPServer1.DefaultPort:=88888;
self.IdTCPServer1.Active:=true;

self.IdTCPClient1.Host:= '127.0.0.1 ';
self.IdTCPClient1.Port:=88888;
try
self.IdTCPClient1.Connect( 5000 );
self.IdTCPClient1.Write( 'aaaaa ' );
showmessage( self.IdTCPClient1.ReadLn() );
self.IdTCPClient1.Disconnect;
except
end;

end;

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
with AThread.Connection do
begin
if ReadLn = 'aaaaa ' then
begin
Write( 'hello world ' );
end;
end;
end;

热点排行