IdTcpServer
uses IdContext //需要引用
属性,方法:
IdTCPServer.Active :=True; //开启服务器
IdTCPServer1.Bindings.Add.IP := '127.0.0.1';//绑定IP
IdTCPServer1.Bindings.Add.Port := ;//绑定端口
事件:
OnConnect : 客户端连接成功触发
OnDisConnect : 客户端断开触发
OnExeCute : 收到客户端数据触发
例子
//像所有客户断发送数据
var
I: Integer;
Context: TIdContext;
begin
with IdTCPServer1.Contexts.LockList do
try
for I := to Count - do
begin
Context := TIdContext(Items[I]);
Context.Connection.IOHandler.Write('Hello,everybody!');
end;
finally
IdTCPServer1.Contexts.UnlockList;
end;
end;
//向某个客户发送数据
var
I: Integer;
Context: TIdContext;
begin
with IdTCPServer1.Contexts.LockList do
try
for I := to Count - do
begin
Context := TIdContext(Items[I]);
if Context.Binding.PeerIP <> '192.168.10.90' then
continue;
Context.Connection.IOHandler.Write('Hello!');
end;
finally
IdTCPServer1.Contexts.UnlockList;
end;
end;
IdTcpClient
属性,方法:
ConnectTimeOut:连接超时
Host:主机IP或域名
IPVersion:Ip版本 ipv4 or ipv6
Name:控件名
Port:主机端口
ReadTimeOut:读取超时
IdTCPClient1.Connect; //连接服务端
IdTCPClient1.Disconnect;//端开连接
IdTCPClient1.Connected;//是否连接成功 返回true 连接成功 IdTCPClient1.IOHandler.WriteLn('aa');// 向服务端发送数据
OnWork事件AWorkMode=wmRead 表示有收到数据

IdTCPServer, idTCPClient的更多相关文章

  1. Indy 10.5.8 for Delphi and Lazarus 修改版(2011)

    Indy 10.5.8 for Delphi and Lazarus 修改版(2011)    Internet Direct(Indy)是一组开放源代码的Internet组件,涵盖了几乎所有流行的I ...

  2. http代理工具delphi源码

    http://www.caihongnet.com/content/xingyexinwen/2013/0721/730.html http代理工具delphi源码 以下代码在 DELPHI7+IND ...

  3. Delphi实例-IdTCPServer和IdTCPClient的使用(支持文件发送)

    相关资料: http://blog.csdn.net/earbao/article/details/46514313 结果注意: 1.Use IdContext.IdGlobal 这两个单元2.不能使 ...

  4. Delphi IdTCPClient IdTCPServer 点对点传送文件

    https://blog.csdn.net/luojianfeng/article/details/53959175 2016年12月31日 23:40:15 阅读数:2295 Delphi     ...

  5. 关于idtcpserver的使用

    原文:http://blog.csdn.net/hnxxcxg/article/details/2798019 用idTCPServer,客户端接上来时,如何取得客户端的IP? IP:=AThread ...

  6. Delphi 局域网点对点文件传输(IdTcpClient控件)

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  7. Delphi组件indy 10中IdTCPServer修正及SSL使用心得

    indy 10终于随着Delphi2005发布了,不过indy套件在我的印象中总是复杂并且BUG不断,说实话,不是看在他一整套组件的面子上,我还是喜欢VCL原生的Socket组件,简洁,清晰.Indy ...

  8. IdUDPServer中文汉字乱码 及IdTCPClient

    官网 http://www.indyproject.org/docsite/html/frames.html?frmname=topic&frmfile=TIdTCPServer_OnExec ...

  9. IdTcpClient简单示例

    procedure TForm1.btnHttpGetClick(Sender: TObject); begin idtcpclnt1.Host := '192.168.10.88'; idtcpcl ...

随机推荐

  1. MySQL使用hugepage

    http://blog.csdn.net/dba_waterbin/article/details/9669929http://www.cnblogs.com/LMySQL/p/4689868.htm ...

  2. js整理常用方法

    javascript对象合并或追加属性的方法 function objMerger(obj1, obj2){ for(var r in obj2){ //eval("obj1."+ ...

  3. mysql datetime、date、time、timestamp区别

    我们看看这几个数据库中(mysql.oracle和sqlserver)如何表示时间 mysql数据库:它们分别是 date.datetime.time.timestamp和year.date :“yy ...

  4. Mini2440 DM9000 驱动分析(一)

    Mini2440 DM9000 驱动分析(一) 硬件特性 Mini2440开发板上DM9000的电气连接和Mach-mini2440.c文件的关系: PW_RST 连接到复位按键,复位按键按下,低电平 ...

  5. Redirect

    Redirect To use this Class, add the following to the top of the file. use Redirect; Redirect::to($pa ...

  6. CSS——伪元素与伪类

    伪类与伪元素 伪类:在特殊性中占据0,0,1,0 :link 向未访问的链接添加特殊的样式.也就是说,链接所指的 URI 尚未出现在用户代理的历史中.这种状态与 :visited状态是互斥的. :vi ...

  7. iOS之自定义UITabBar替换系统默认的(添加“+”号按钮)

    自定义UITabBar替换系统默认的,目的是为了在UITabBar中间位置添加一个“+号按钮”,下面我们来聊聊具体的实现. 1.自定义WBTabBar,让其继承自UITabBar,代码如下: // / ...

  8. PHP免费API调用,使用(CURL)

    <?phpclass GetApiModel{//获取第三方API //获取身份证信息 //返回json /*{ "errNum": 0, "retMsg" ...

  9. FastDFS配置过程

    在我的生产环境中利用FastDFS实现动静分离的方案

  10. loadjs异步加载javascript回调

    function loadjs(url,callback){    var script=document.createElement('script');     script.type=" ...