Salome HOME
add method NameChanged to update title name
[modules/kernel.git] / src / Communication / SALOME_Comm_i.cxx
index e706c8d538d1970ce2705bd888219e026f2c7e5e..30df15db153b3c4fcefefaa425e5b451a357290e 100644 (file)
@@ -1,28 +1,31 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "SALOME_Comm_i.hxx"
 #ifndef WIN32
+#ifndef __APPLE__
 #include <rpc/xdr.h>
 #endif
+#endif
 #include "omniORB4/poa.h"
 #include "omnithread.h"
 #include "Utils_SINGLETON.hxx"
@@ -30,7 +33,6 @@
 #include "utilities.h"
 
 #include "SenderFactory.hxx"
-using namespace std;
 
 #ifndef WIN32
 CORBA::ORB_var &getGlobalORB(){
@@ -240,7 +242,7 @@ SALOME_MPISender_i::~SALOME_MPISender_i(){
 SALOME::MPISender::param* SALOME_MPISender_i::getParam()
 {
   char stag[12];
-  int myproc,i=0;
+  int i=0;
 
   SALOME::MPISender::param_var p = new SALOME::MPISender::param;
   MPI_Comm_rank(MPI_COMM_WORLD,&_cproc);
@@ -315,7 +317,6 @@ void* SALOME_MPISender_i::myThread(void *args)
 void SALOME_MPISender_i::close(const SALOME::MPISender::param& p)
 {
   std::string service(p.service);
-  const char *st=p.service;
   void *r;
   _newThr->join(&r);
   MPI_Comm_free(&_com); 
@@ -378,7 +379,7 @@ std::string SALOME_SocketSender_i::inetAddress()
       host = gethostbyname(s);
       if (host != NULL)
          inet_ntop(AF_INET, (struct in_addr *) *host->h_addr_list, 
-                  t, INET_ADDRSTRLEN);
+                   t, INET_ADDRSTRLEN);
    }
    return std::string(t);
 }
@@ -432,19 +433,19 @@ void* SALOME_SocketSender_i::myThread(void *args)
 
       *errorFlag = false;
       while( n < *lgrTabToSend*sizeof(double) ){
-       m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(double)-n);
-       if( m < 0 ){
-         if( *clientSockfd >= 0 ){
-           ::close(*clientSockfd);
-           *clientSockfd = -1;
-         }
-         if( *serverSockfd >= 0 ){
-           ::close(*serverSockfd);
-           *serverSockfd = -1;
-         }
-         *errorFlag = true;
-       }
-       n += m;
+        m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(double)-n);
+        if( m < 0 ){
+          if( *clientSockfd >= 0 ){
+            ::close(*clientSockfd);
+            *clientSockfd = -1;
+          }
+          if( *serverSockfd >= 0 ){
+            ::close(*serverSockfd);
+            *serverSockfd = -1;
+          }
+          *errorFlag = true;
+        }
+        n += m;
       }
       xdr_destroy( &xp );
 
@@ -458,19 +459,19 @@ void* SALOME_SocketSender_i::myThread(void *args)
 
       *errorFlag = false;
       while( n < *lgrTabToSend*sizeof(int) ){
-       m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(int)-n);
-       if( m < 0 ){
-         if( *clientSockfd >= 0 ){
-           ::close(*clientSockfd);
-           *clientSockfd = -1;
-         }
-         if( *serverSockfd >= 0 ){
-           ::close(*serverSockfd);
-           *serverSockfd = -1;
-         }
-         *errorFlag = true;
-       }
-       n += m;
+        m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(int)-n);
+        if( m < 0 ){
+          if( *clientSockfd >= 0 ){
+            ::close(*clientSockfd);
+            *clientSockfd = -1;
+          }
+          if( *serverSockfd >= 0 ){
+            ::close(*serverSockfd);
+            *serverSockfd = -1;
+          }
+          *errorFlag = true;
+        }
+        n += m;
       }
       xdr_destroy( &xp );
 
@@ -502,7 +503,7 @@ void SALOME_SocketSender_i::initCom() throw(SALOME::SALOME_Exception)
 
   /* Association of socket with a port */
   if( ::bind(_serverSockfd, (struct sockaddr *) & serv_addr, 
-          sizeof(struct sockaddr)) < 0 ) {
+           sizeof(struct sockaddr)) < 0 ) {
     closeCom();
     es.type = SALOME::COMM;
     es.text = "error bind Socket exception";