序。在项目中添加一个数据模块(DataModule),也可以不使用数据模块,直接在主窗体上添加组件。
2) 在数据模块中添加连接SocketConnection 组件,通过程序来设置其相关的Address、ServerName 等属性,实现过程如下:
在登录成功时设置SocketConnection:
procedure Tloginform.okbitClick (Sender: TObject);
begin
。。。
DM.SocketConnection1. Address:= Serverip; // Serverip 为服务器计算机ip 地址,由登录窗口输入
DM.SocketConnection1.ServerName:='scoreserver.scoresrv';
try
DM SocketConnection1.Connected:=true;
except
showmessage('连接错误!');
end;