#1 2016-06-10 07:04:59

jaclas
Member
Registered: 2014-09-12
Posts: 215

Port in use

How check that port is already in use when creating a server TSQLHttpServer (http.sys)?

Offline

#2 2016-06-10 07:33:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: Port in use

There is no built-in feature, but to try binding the port...

But if you register the port using the http.sys registering process, I guess the port would be reserved for http.sys process.

Offline

#3 2016-06-10 07:53:41

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 516

Re: Port in use

@ab you are right, if a port is once registered it stays registered. The matter is that if you also register it for http/https access...

We had the problem at a customer where we switched from https to http and could "sometimes" (very serious) could not register Port.
As solution we made a little service start script which unregisters our ports before service start

// netsh http show urlacl

netsh http delete urlacl http://+:5001/root
netsh http delete urlacl https://+:5001/root
net start ourservice

hopefully this - "workaround" can help

Last edited by itSDS (2016-06-10 07:54:32)


Rad Studio 12.1 Santorini

Offline

#4 2016-06-10 10:12:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,603
Website

Re: Port in use

You could just change the method to useHttpApi instead of useHttpApiRegisteringURI, with having previously registered the URI.

And you have the "deletion" feature using THttpApiServer.RemoveUrl instead of netsh commands (but need admin rights).

Offline

#5 2016-06-10 10:31:27

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Port in use

My approach: every time the program is being installed, it will first try to "delete" the url registration, then does the registration.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB