se; {标志清零}
end;
file://主窗口建立…
procedure TForm1.FormCreate(Sender: TObject);
begin
Service_Enabled:=false;
timer2.Enabled:=true; {窗口建立时,打开定时器}
end;
file://窗口关闭时…
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
timer1.Enabled:=false; {关闭定时器}
if Service_Enabled then
serversocket1.Active:=false; {退出
程序时关闭服务}
end;
file://退出
程序按钮…
procedure TForm1.N01Click(Sender: TObject);
begin
form1.Close; {退出
程序}
end;
file://开启代理服务后…
procedure TForm1.ServerSocket1Listen(Sender: TObject;
Socket: TCustomWinSocket);
begin
Service_Enabled:=true; {置正在服务标志}
N11.Enabled:=false;
N21.Enabled:=true;
end;
file://被代理端连接到代理服务器后,建立一个会话,并与套接字绑定…
procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
var
i,j: integer;
begin
j:=-1;
for i:=1 to sessions do {查找是否有空白项}
if not session[i-1].Used and not session[i-1].CSocket.active then
begin
j:=i-1; {有,分配它}
session[j].Used:=true; {置为在用}
break;
end
else
if not session[i-1].Used and session[i-1].CSocket.active then
session[i-1].CSocket.active:=false;
if j=-1 then
begin {无,新增一个}
j:=sessions;
inc(sessions);
setlength(session,sess