]> SALOME platform Git repositories - tools/libbatch.git/blobdiff - src/Core/Batch_BatchManager.cxx
Salome HOME
Fixed errors in CMake FindXXX modules. Fixed Windows compilation errors.
[tools/libbatch.git] / src / Core / Batch_BatchManager.cxx
index d4744af18b5cac9aaeb5d090b0b214e4079cd966..a7e6d61f243d9a758e342015f8701e72982d2776 100644 (file)
@@ -20,7 +20,7 @@
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 /*
- * BatchManager.cxx : 
+ * BatchManager.cxx :
  *
  * Auteur : Ivan DUTKA-MALEN - EDF R&D
  * Date   : Septembre 2003
@@ -61,8 +61,19 @@ namespace Batch {
 //   }
   BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent)
   {
+#ifdef WIN32
+    WSADATA wsaData;
+    WSAStartup(MAKEWORD(2, 2), &wsaData);  // Initialize Winsock
+#endif
+
     // On verifie que le hostname est correct
-    if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network
+    struct hostent* res = gethostbyname(_hostname.c_str());
+
+#ifdef WIN32
+    WSACleanup();  // Finalize Winsock
+#endif
+
+    if (!res) { // hostname unknown from network
       string msg = "hostname \"";
       msg += _hostname;
       msg += "\" unknown from the network";
@@ -109,7 +120,7 @@ namespace Batch {
 //   {
 //     // Nothing to do
 //   }
-   
+
 //   // Methode pour le controle des jobs : suspend un job en file d'attente
 //   void BatchManager::holdJob(const JobId & jobid)
 //   {