DELPHI XE 10.3 三层数据库应用 尝鲜 之一

按照https://blog.csdn.net/qq_25439957/article/details/90293387安装好TServerSocket和TCLIENTSocket;

在DELPHI XE10.3中新建一个 VCL应用。取名为Pserver,配置如下

object SSKServer: TServerSocket
    Active = True
    Port = 2018             //---------------------->客户端必须跟这里一致。否联接不上
    ServerType = stNonBlocking
    OnClientRead = SSKServerClientRead 
    Left = 140
    Top = 48
  end;

  object Memo1: TMemo
    Left = 24
    Top = 248
    Width = 393
    Height = 201
    Lines.Strings = (
      'Memo1')
    TabOrder = 0
  end

procedure TForm2.SSKServerClientRead(Sender: TObject; Socket: TCustomWinSocket);
begin
memo1.lines.add(Socket.ReceiveText);
end;
 


在DELPHI XE10.3中新建另一个 VCL应用。取名为Pclient,配置如下

object SCKClient: TClientSocket
    Active = True
    ClientType = ctNonBlocking
    Host = 'winserver'   //------------------->这是服务器的计算机名
    Port = 2018

    OnConnect = SCKClientConnect
    Left = 168
    Top = 104
  end

 

procedure Tdmclient.SCKClientConnect(Sender: TObject; Socket: TCustomWinSocket);
begin
  Socket.SendText('您好') ;
end;
 


OK

 

先运行服务器,再运行客户端

结果在服务器端的MEMO1中显示    您好

 

 

具体应用请看下一节

你可能感兴趣的:(delphi人生,delphi,数据库)