delphi 10.1的TSeverSocket和TClientSocket組件哪裏去了,TClientSocket客戶端實時發送消息

 

一、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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章