Question ABL Server Socket - How to Avoid port in use scenario

Cecil

19+ years progress programming and still learning.
Hi

I had an interesting problem today where I had an Openege GUI desktop application open up a local TCP port using the ABL server socket handle.

It was working in development and testing and of cause when it when into production it had issues.
The desktop GUI Application was running on Citrix and when a second user opened the application, they got an error saying that the socket could not be opened because the port was in use.

I have resolved this issue, but I'm interested in how you would avoid the clash of trying to open the same port number?

OE: 11.7.x
OS: Windows server or something.
 

TomBascom

Curmudgeon
I would think that you would want to implement some sort of "port range" scheme similar to Progress' -minport -maxport approach and choose something else in the range when a collision happens. If you manage it with a db table you could avoid the whole "trial and error" aspect of things.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
If your program creates a TCP server, it has clients connecting to it. How do the clients know which port number to connect to?
 

Cecil

19+ years progress programming and still learning.
A bit more details. I’m using the ABL server sockets to act as a mini–Web server to handle OAuth redirect callback to the desktop PC.

As part of the authorisation request I was specifying, a URL of localhost and a port number.
the range of port numbers was from 8115 to 8120. originally i was randomly picking a port number in the available range but too many times multiple desktop instances were choosing the same port number.

my solution was to use .NET and look ahead to see what port numbers was available before choosing the next available port number.

I did not want to do loop and try test/fail scenario.

If you are interested i can share the code.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
If these are database clients, you could maintain a pool of server ports in a table and update their state as they are used.
 
Top