diff options
-rw-r--r-- | param.ccl | 9 | ||||
-rw-r--r-- | src/Sockets.c | 25 |
2 files changed, 34 insertions, 0 deletions
@@ -60,6 +60,15 @@ BOOLEAN use_pthreads "Use a threaded implementation if possible ?" { } "no" +BOOLEAN announce_server_url "Announce HTTPD server URL into an HTML file ?" +{ +} "no" + +STRING announce_server_url_outdir "Where to write the HTTPD server URL HTML file to ?" +{ + ".+" :: "Any string" +} "." + ################################################################## # Tuning parameters diff --git a/src/Sockets.c b/src/Sockets.c index 38a5ced..000a363 100644 --- a/src/Sockets.c +++ b/src/Sockets.c @@ -11,6 +11,7 @@ @@*/ #include "cctk.h" +#include "cctk_Parameters.h" #include "util_Network.h" #include <stdio.h> @@ -76,6 +77,10 @@ CCTK_FILEVERSION(CactusConnect_HTTPD_Sockets_c) #define MSG_NOSIGNAL 0 #endif +/* HTML filename to take the server URL */ +#define SERVER_URL_FILENAME "server_url.html" + + typedef enum {closed, open} httpSocketState; typedef struct HTTPSocket @@ -140,6 +145,8 @@ int HTTP_SetupServer(int port, int queue_size, int hunt) { char hostname[1025]; int realport; + DECLARE_CCTK_PARAMETERS + /* Some systems need special logic for starting up TCP. */ InitialiseTCP(); @@ -159,6 +166,24 @@ int HTTP_SetupServer(int port, int queue_size, int hunt) httpport = hunt ? realport : port; printf("Server started on http://%s:%lu/\n", hostname, httpport); + if (announce_server_url) + { + char *filename; + FILE *file; + + + CCTK_CreateDirectory (0755, announce_server_url_outdir); + filename = (char *) malloc (strlen (announce_server_url_outdir) + 20); + sprintf (filename, "%s/%s", announce_server_url_outdir, SERVER_URL_FILENAME); + file = fopen (filename, "w"); + if (file) + { + fprintf (file, "HTTPD server started on <A HREF=\"http://%s:%lu\">http://%s:%lu</A>", + hostname, httpport, hostname, httpport); + fclose (file); + } + free (filename); + } minsock = sock; maxsock = sock; |