Indy的IdTCPClient怎么用的?

nevergetwin 2008-08-27 10:03:59
连接上服务器后,接收到服务器消息后会触发什么事件?
怎么接收服务器数据?
我就想实现一个简单的TCP通信的客户端的代码,哪位能提供一下,谢谢!
...全文
195 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
nevergetwin 2008-09-23
  • 打赏
  • 举报
回复
怎么接收服务端数据?我要代码,谢谢
nevergetwin 2008-09-01
  • 打赏
  • 举报
回复
我怎么看不见回复呢?显示回复6次,但是打开却显示回复次数:0,什么都没有!?
shuihan20e 2008-08-28
  • 打赏
  • 举报
回复
建议看下indy带的DEMO
fangsp 2008-08-28
  • 打赏
  • 举报
回复
触发的是OnConnected事件
fangsp 2008-08-28
  • 打赏
  • 举报
回复
if CBClientActive.Checked = true then
begin
for i := 0 to strtoint(Edit_ClientNum.text) - 1 do
begin
tcpClient[i] := TIdTCPClient.Create(self);
// tcpClient[i].Host := '192.168.0.54';
//tcpClient[i].Port := 5000;

end;
try
for i := 0 to strtoint(Edit_ClientNum.text) - 1 do
begin
if (Edit2.Text<>'') and (Edit3.Text<>'') then
begin
try
tcpClient[i].Host:=Edit2.Text;
tcpClient[i].Port:=strtoint(Edit3.text);
tcpClient[i].Connect(); // in Indy < 8.1 leave the parameter away
GetValue(i);
AppendTreeList(RecordList);
ProgramDelay(10);
except
end;
end;
end;
ClientHandleThread := TClientHandleThread.Create(True);
ClientHandleThread.FreeOnTerminate:=True;
ClientHandleThread.Resume;
except
on E: Exception do MessageDlg ('Error while connecting:'+#13+E.Message, mtError, [mbOk], 0);
end;
end
else
begin
ClientHandleThread.Terminate;
//Client.Disconnect;
end;

//ButtonSend.Enabled := Client.Connected;
//CBClientActive.Checked := Client.Connected;

这是连接的一个问题 你看看
如果还不能解决 在给代码
记得给分喽
lyguo 2008-08-28
  • 打赏
  • 举报
回复
TcpClient.host:='**.**.**.**';
TcpClient.port:=****;
TcpClient.Connect(300);
...
lyguo 2008-08-28
  • 打赏
  • 举报
回复
IdTCPClient.connect
IdTCPClient.sendbuffer(@.,sizeof())
oushengfen 2008-08-28
  • 打赏
  • 举报
回复
不会有什么消息,要自己去读,判断.
这样的例子,网上多的是啊,自带的也有,自己去看啊

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧