Jump to content

How to set the server port from my.ini file


55143681

Recommended Posts

As you know,You can setup the listen port from ServerModule->port property,

Now ,I want to setup the listen port from a my.ini file,

when my project start ,it will read my.ini and get the listen port,

then my project will listen the port.

what I want to say is that how to change my server port from my.ini file.

Link to comment
Share on other sites

Uses IniFiles;

procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'AppIni.ini');
  try
    Port := Ini.ReadInteger('Settings', 'Port', 8077);
  finally
    Ini.Free;
  end;
end;

What type of application?

Link to comment
Share on other sites

Hi,

Can we without (or must be with) mutex disable start of unigui application/service if port already used ?

Can we disable starting two application on one port some how.

I have problem with that, if I start two unigui application on one port, second shows error but port is can not usable anymore after second application was startet with error

Link to comment
Share on other sites

On 1/8/2021 at 11:57 PM, Sherzod said:

Uses IniFiles;

procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'AppIni.ini');
  try
    Port := Ini.ReadInteger('Settings', 'Port', 8077);
  finally
    Ini.Free;
  end;
end;

What type of application?

I know that ,thanks,

but in the before unigui version,

the follow code will have error:

UniServerModule()->Port=8077;

Now,the code works well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...