一、TSeverSocket和TClientSocket组件安装
转载:https://www.cnblogs.com/blogpro/p/11344639.html
delphi 7,delphi2007 delphi 2009 delphi 2010的TSeverSocket和TClientSocket组件哪里去了
Borland is deprecating the use of the TServerSocket
and TClientSocket from the unit ScktComp. It is
recommended that you use the Indy components for
socket operations. The TServerSocket and
TClientSocket will no longer be installed on the
component palette by default. If you require the
use of these components then you can install
the design time package named dclsockets70.bpl or dclsockets100.bpl dclsockets140.bpl ,
found in your bin directory. For deployment with
runtime packages, you will need to deploy rtl70.bpl
and any other required packages
偶简单翻译了一下:TClientSocket 本来是D5默认安装的,但是D7使用的Indy组件后,就没有默认安装了,如果你喜欢这个组件,可以在delphi 7,
delphi2007 delphi 2009 delphi 2010的安装目录bin文件夹找到dclsockets70.bpl or dclsockets100.bpl dclsockets140.bpl 组件包,安装上去就OK了.
dclsockets70.bpl or dclsockets100.bpl dclsockets140.bpl 是TCientSocket和TServerSocket必需的运行包.
原文确实好文章,很多可以参考:
侵删。。
二、socket客户端直接发送请求:
转载:https://blog.csdn.net/newzhhsh/article/details/2905874
构造函数中创建TClientSocket,那么TClientSocket还是属于主线程,不属于 这个线程。如果你是在线程的Execute()中创建TClientSocket,那么TClientSocket属于这个线程,但是此时你无法使用OnRead来读取,
必须将TClientSocket的ClientType设为ctBlocking
procedure TForm1.Button3Click(Sender: TObject);
begin
memo1.Lines.Add('111111');
ClientSocket1.Host := 'localhost';
ClientSocket1.Port:=9092;
ClientSocket1.ClientType:=ctBlocking; //阻塞方式,实时发送socket消息
ClientSocket1.Open ;
memo1.Lines.Add('2222 open ');
ClientSocket1.Socket.SendText('11111111111111');
memo1.Lines.Add('3333 send ok ');
ClientSocket1.Close;
memo1.Lines.Add('4444 close end ');
end;
侵删。。
三、Delphi TclientSocket和TserverSocket用法(1)
里面有服务端,客户端的写法。
https://www.tuicool.com/articles/v6zEvi