Jump to content

HyperServer


MOGSY

Recommended Posts

The IP or Port is already in use -or- the IP does not exist.

UniGUI uses default settings for IP and Port unless you override them.

I use the following:-

procedure TUniServerModule.UniGUIServerModuleBeforeInit(Sender: TObject);

...

AddNewBindingsFlag:= ?
HttpPort:= ?
BindToIpStr:= ?
SslPort:= ?
SslPassword:= ?  

  //////////////////////////////////////////////////////////////////////////////
  if AddNewBindingsFlag = True then begin
    Bindings.BeginUpdate;
    // Remove Any IDE Bindings
    Bindings.Clear;
    // Add binding for http
    with Bindings.Add do begin
      IP:= '';
      Port:= 0;
    end;
    Bindings.EndUpdate;
    // Set http binding/port
    if UniServerModule.Bindings.Count > 0 then begin
      // Set Binding [0] http
      UniServerModule.Bindings.Items[0].Port:= HttpPort;
      UniServerModule.Bindings.Items[0].IP:=   BindToIpStr;
      UniServerModule.Bindings.Items[0].BroadcastEnabled:= True;
    end else begin
      UniServerModule.Port:= HttpPort; 
    end;
    //////////////////////////////////////////////////////////////////////////////
    if UseSslFlag = True then begin
      SSL.SSLBindings.BeginUpdate;
      // Remove Any IDE Bindings
      SSL.SSLBindings.Clear;
      // Add binding for https
      with SSL.SSLBindings.Add do begin
        IP:= '';
        Port:= 0;
      end;
      SSL.SSLBindings.EndUpdate;
      // Set https binding/port
      if UniServerModule.SSL.SSLBindings.Count > 0 then begin
        // Set Binding [0] https
        UniServerModule.SSL.SSLBindings.Items[0].Port:= SslPort;
        UniServerModule.SSL.SSLBindings.Items[0].IP:= BindToIpStr;
        UniServerModule.SSL.SSLBindings.Items[0].BroadcastEnabled:= True;
      end else begin
        UniServerModule.SSL.SSLPort:= 0;
      end;
      // Assign Certificate 
      SSL.SSLOptions.RootCertFile:= UniServerModule.StartPath + 'root.pem';
      SSL.SSLOptions.CertFile:=     UniServerModule.StartPath + 'cert.pem';
      SSL.SSLOptions.KeyFile:=      UniServerModule.StartPath + 'key.pem';  
      SSL.SSLPassword:=             SslPassword;
      SSL.Enabled:=                 True;
    end; // UseSslFlag
  end; // AddNewBindingsFlag

 

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...