Hello List!

I have two questions about WServer error handling:

(This is wt-3.3.3 compiled with mingw-w64 on windows 7.)

First, I see no errors when trying to start a wthttpd server on an
already bound port.  What behavior should I expect?

Details:  I've built a "minimal" wthttpd server -- it just servers
html files, so no WApplication.  I run two copies of it at the
same time, both launched with "--http-port=80".  The first
copy works, services http connections, and serves the html
pages.  The second copy reports no errors, and doesn't receive
any http requests -- presumably because all of the port-80 traffic
goes to the first copy.

My understanding is that the first copy binds to port 80, and
everything works.  I would expect that the second copy fails
to bind to port 80, which would seem to be to be an error
condition.  But the second copy reports no errors.

Here is the relevant code:

   int main (int argc, char *argv[]) {
     try {
       WServer server;
       server.setServerConfiguration (argc, argv);
       if (server.start())  WServer::waitForShutdown();
       else  cout << "error on server.start()" << endl;
     }
     catch (const WException& e) {
       cout << "WException caught, e.whatA() = " << e.what() << endl;
     }
     return 0;
   }

Here's how I launch both copies:

   minimal_wt3 --http-address=0.0.0.0 --http-port=80
--deploy-path=/dummy --docroot=.

A little more detail:  If I kill the first copy of the wthttpd server (and
just leave the second running, without restarting it or anything), the
second copy now responds to incoming connections, serves the
html pages, etc.  Is this expected?

Here;s the output from the second copy:

   Option no-compression is implied because wthttp was built without
zlib support.
   [2016-Oct-31 08:21:09.352845] 4236 - [info] "config: reading Wt
config file: c:/witty/wt_config.xml (location = '')"
   Option no-compression is implied because wthttp was built without
zlib support.
   [2016-Oct-31 08:21:09.372845] 4236 - [info] "WServer/wthttp:
initializing built-in wthttpd"
   [2016-Oct-31 08:21:09.372845] 4236 - [info] "wthttp: started
server: http://0.0.0.0:80";
   127.0.0.1 - - [2016-Oct-31 08:22:34.961484] "GET /nonexistant.html
HTTP/1.1" 404 85

Note, between the last two lines -- that is, before the line:

   127.0.0.1 - - [2016-Oct-31 08:22:34.961484] "GET /nonexistant.html
HTTP/1.1" 404 85

I killed the first server.  I then browsed to the "nonexistant.html" url,
and the second server correctly responds with a 404 (because that
html page doesn't exist).


My second questions is about the WServer documentation and
error handling.

The documentation for  WServer::start():

   WTCONNECTOR_API bool Wt::WServer::start()

   Starts the server in the background.

   Returns whether the server could be successfully started.

   Exceptions
   Exception: indicates a problem starting the server.

This seems to be saying that when WServer::start() encounters
an error (regardless of whether my above example counts as
an error), the error condition is reported by returning false and
by throwing an exception.  Of course, you can't actually do
both.

Are there two different classes of WServer::start() errors (maybe
for historical reasons), some of which are reported with a false
return value, and others that are reported with a thrown exception?

Anyway, what are the recommended best practices for handling
WServer::start() error conditions?


Thanks.


K. Frank

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to