NetTalk Central

Author Topic: How to detect if webserver port is already open?  (Read 2159 times)

Neil Porter

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
How to detect if webserver port is already open?
« on: January 10, 2013, 01:48:43 AM »
I'm running a simple Nettalk Soap Server, as a service.

I've noticed that at random times it just GPF's. Because I've added the GPF Reporter template, I've configured the service to restart, so it doesn't cause me too much trouble.

Occasionally, the service restarts so quickly, that the webserver doesn't seem to be able to bind to the port. Everything seems to runs OK, but I just can't connect to the server. Manually restarting the service fixes everything. I've tried putting a SLEEP(5000) statement into the code to make the program pause before initializing the port, and this seems to improve matters, but its a bit clunky.

What I'd like to do it test to see if the port was correctly initialized, and then loop x number of times retrying before giving up.

Can I test for some kind of error in ThisWebServer.Open() or is this situation something that Nettalk won't actually be able to detect?

Regards,

Neil Porter

Nettalk 6.51
Clarion 11.0.13244
NetTalk 11.04

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11239
    • View Profile
Re: How to detect if webserver port is already open?
« Reply #1 on: January 11, 2013, 04:17:29 AM »
hmm - I don't think there's any obvious way to detect it. I'll have to think a bit. There must be some sort of error generated, but the open is asynchronous (most of the time) so you'd have to catch it. The sleep option is obviously a good one anyway.

cheers
Bruce