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. 常用免费的WebServices地址

    天气预报Web服务,数据来源于中国气象局 公用事业http://www.webxml.com.cn/WebServices/WeatherWebService.asmx 中国股票行情分时走势预览缩略图 ...

  2. css实现响应式全屏背景

    利用css中 background-size:cover  填充整个viewport 注意: 一张背景图像素5000px*5000px在pc端 缩放都基本满足要求 不会出现模糊失真: 但是在移动端使用 ...

  3. 为ListView添加头和脚

      转自:https://software.intel.com/zh-cn/blogs/2014/12/15/android-listview-addheaderview-addfooterview ...

  4. JAVA_JSON_example

    package cn.kjxy.JSON; import java.util.List; import org.json.JSONArray; import org.json.JSONExceptio ...

  5. js解析XML

    //在当前页面内追加换行标签和指定的HTML内容function w( html ){    $(document.body).append("<br/>" + htm ...

  6. Linux系统故障处理案例(一)

    运行环境:CentOS6.7 故障原因: 昨天在线执行命令yum -y update 在命令执行途中,强制中断并直接运行poweroff命令关机.再次开机出现如图所示故障指示: 根据提示信息分析,可能 ...

  7. BIO与NIO、AIO的区别

    IO的方式通常分为几种,同步阻塞的BIO.同步非阻塞的NIO.异步非阻塞的AIO. 一.BIO      在JDK1.4出来之前,我们建立网络连接的时候采用BIO模式,需要先在服务端启动一个Serve ...

  8. [记录]calculate age based on date of birth

    calculate age based on date of birth know one new webiste:eval.in run php code

  9. MySQL - 日志管理

    在 MySQL 中,有 4 种不同的日志,分别是错误日志.二进制日志.查询日志和慢查询日志. 错误日志 错误日志记录了 MySQL 启动和停止时以及服务器在运行过程中发生严重错误时的相关信息. 查看错 ...

  10. spark stream初探

    spark带了一个NetworkWordCount测试程序,用以统计来自某TCP连接的单词输入: /usr/local/spark/bin/run-example streaming.NetworkW ...