在SOCKET 的任何事件下都可写入
socket.RemoteAddress;获取对方的IP ,剩下的事情好象就是你所谓的数据标识来区分不同
联结用户了吧/
const MAXRemote=16; //假设联结用户数
var Remote:array[1..MAXRemote] of string;
function Tfrm_main.Get_RemotIP(ASCK:TCustomWinSocket):byte;
var i:byte;
BEGIN
Result:=0;
for i:=0 to MAXRemote-1 do
begin
if Remote.IP = ASCK.RemoteAddress then
begin
Result:=i;
Break;
end
end;
END
procedure Tfrm_main.ServerSocket1ClientDisconnect(Sender: TObject; Socket: TCustomWinSocket);
var i:byte;
begin
i:=Get_RemotIP(Socket);
showmessage(socket.RemoteAddress+':断开联结!!!');
Remote.IP:=socket.RemoteAddress;
end;
procedure Tfrm_main.ServerSocket1ClientConnect(Sender: TObject; Socket: TCustomWinSocket);
var i:byte;
begin
i:=Get_RemotIP(Socket);
Server.IP:=socket.RemoteAddress;
showmessage(socket.RemoteAddress+':联结成功!!!');
end;