F Firpas Active Member Licensed User Longtime User Feb 10, 2015 #1 Hi to everybody: I'm Trying to initialize a ServerSocket Code: Sub Process_Globals ... Private SvrSocket1 As ServerSocket ... Sub Service_Create SvrSocket1.Initialize(2025, "SvrSocket1") but .... How do I can know if the port is in use by another application or service? Thanks in advance
Hi to everybody: I'm Trying to initialize a ServerSocket Code: Sub Process_Globals ... Private SvrSocket1 As ServerSocket ... Sub Service_Create SvrSocket1.Initialize(2025, "SvrSocket1") but .... How do I can know if the port is in use by another application or service? Thanks in advance
giga Well-Known Member Licensed User Longtime User Feb 10, 2015 #2 I think this one may be hard as applications/services can use many different ports, based on how the are written. If the said application/service is not running at the time you "checked" the port you would not know that is the one it uses. Ports open and close so catching them may be the biggest challenge. Upvote 0
I think this one may be hard as applications/services can use many different ports, based on how the are written. If the said application/service is not running at the time you "checked" the port you would not know that is the one it uses. Ports open and close so catching them may be the biggest challenge.
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2015 #3 You can add a Try / Catch block. If it fails switch to an alternative port. The problem is that you will need to also switch to the alternative port in the client. This is how the designer works for example. The IDE tries to connect to one port and if it fails it tries to connect to the second port. Upvote 0
You can add a Try / Catch block. If it fails switch to an alternative port. The problem is that you will need to also switch to the alternative port in the client. This is how the designer works for example. The IDE tries to connect to one port and if it fails it tries to connect to the second port.
F Firpas Active Member Licensed User Longtime User Feb 12, 2015 #4 Hi Thanks for yours replay. I had resolved with the following code: Code: Dim MyPort as int = 2020 Dim Sw As Boolean = False Do While Sw = False Try SvrSocket1.Initialize(MyPort, "SvrSocket1") Sw = True Catch MyPort = MyPort + 1 End Try Loop Thanks Upvote 0
Hi Thanks for yours replay. I had resolved with the following code: Code: Dim MyPort as int = 2020 Dim Sw As Boolean = False Do While Sw = False Try SvrSocket1.Initialize(MyPort, "SvrSocket1") Sw = True Catch MyPort = MyPort + 1 End Try Loop Thanks