]> SALOME platform Git repositories - modules/kernel.git/blob - src/Communication/SALOME_Comm_i.cxx
Salome HOME
Build KERNEL with native openmpi on CentOS-8
[modules/kernel.git] / src / Communication / SALOME_Comm_i.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SALOME_Comm_i.hxx"
24 #ifndef WIN32
25 #ifndef __APPLE__
26 #ifdef HAVE_SOCKET
27 #include <rpc/xdr.h>
28 #endif
29 #endif
30 #endif
31 #include "omniORB4/poa.h"
32 #include "omnithread.h"
33 #include "Utils_SINGLETON.hxx"
34 #include "Utils_ORB_INIT.hxx"
35 #include "utilities.h"
36
37 #include "SenderFactory.hxx"
38
39 #ifndef WIN32
40 CORBA::ORB_var &getGlobalORB(){
41   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
42   CORBA::ORB_var &orb = init(0,0);
43   return orb;
44 }
45 #endif
46
47 /*! Return the C++ data associated to the array to transmit.
48   Used when sender and receiver are colocalized.
49  */
50 const void *SALOME_Sender_i::getData(long &size) const{
51   size=_lgrTabToSend;
52   return _tabToSend;
53 }
54
55 /*! Return the sizeof() of each component of the generic array
56  */
57 int SALOME_Sender_i::getSizeOf() const {
58   return _sizeOf;
59 }
60
61 /*! Unique constructor */
62 SALOME_Sender_i::SALOME_Sender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):_tabToSend(tabToSend),_lgrTabToSend(lgrTabToSend),_sizeOf(sizeOf),_ownTabToSend(ownTabToSend){
63 }
64
65 /*! To force ownerShip status */
66 void SALOME_Sender_i::setOwnerShip(bool own)
67 {
68   _ownTabToSend=own;
69 }
70
71 /*! Method for the remote destroy of the current servant. This method is used by the receiver to destroy the sender when the transfert is complete.
72  */
73 void SALOME_Sender_i::release()
74 {
75   PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this);
76   _default_POA()->deactivate_object(oid);
77   _remove_ref();
78 }
79
80 SALOME_SenderDouble_i::SALOME_SenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend)
81 {
82 }
83
84 /*! Destructor.
85  */
86 SALOME_SenderDouble_i::~SALOME_SenderDouble_i()
87 {
88   if(_ownTabToSend)
89     delete [] (double *)_tabToSend;
90 }
91
92 /*! Return a new sender of the same array but with an another protocol and delegates to the returned sender the ownership of array.
93  */
94 SALOME::SenderDouble_ptr SALOME_SenderDouble_i::buildOtherWithProtocol(SALOME::TypeOfCommunication type)
95 {
96   return SenderFactory::buildSender(type,this);
97 }
98
99 /*! Method to establish if the CORBA object referred by pCorba is colocalized.\n
100   If it is, the pointer to the servant that incarnates the CORBA object is returned.
101 */
102 SALOME_SenderDouble_i *SALOME_SenderDouble_i::find(SALOME::SenderDouble_ptr pCorba){
103   PortableServer::ServantBase *ret;
104   try {
105     ret=PortableServer::POA::_the_root_poa()->reference_to_servant(pCorba);
106   }
107   catch(...){
108     return 0;
109   }
110   ret->_remove_ref();
111   return dynamic_cast<SALOME_SenderDouble_i *>(ret);
112 }
113
114 SALOME_SenderInt_i::SALOME_SenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend)
115 {
116 }
117
118 /*! Destructor.
119  */
120 SALOME_SenderInt_i::~SALOME_SenderInt_i()
121 {
122   if(_ownTabToSend)
123     delete [] (int *)_tabToSend;
124 }
125
126 /*! Return a new sender of the same array but with an another protocol.
127  */
128 SALOME::SenderInt_ptr SALOME_SenderInt_i::buildOtherWithProtocol(SALOME::TypeOfCommunication type)
129 {
130   return SenderFactory::buildSender(type,this);
131 }
132
133 /*! Method to establish if the CORBA object referred by pCorba is colocalized.\n
134   If it is, the pointer to the servant that incarnates the CORBA object is returned.
135 */
136 SALOME_SenderInt_i *SALOME_SenderInt_i::find(SALOME::SenderInt_ptr pCorba){
137   PortableServer::ServantBase *ret;
138   try {
139     ret=PortableServer::POA::_the_root_poa()->reference_to_servant(pCorba);
140   }
141   catch(...){
142     return 0;
143   }
144   ret->_remove_ref();
145   return dynamic_cast<SALOME_SenderInt_i *>(ret);
146 }
147
148 SALOME_CorbaDoubleNCSender_i::SALOME_CorbaDoubleNCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend){
149 }
150
151 SALOME_CorbaDoubleNCSender_i::~SALOME_CorbaDoubleNCSender_i(){
152 }
153
154 CORBA::ULong SALOME_CorbaDoubleNCSender_i::getSize(){
155   CORBA::ULong ret=_lgrTabToSend;
156   return ret;
157 }
158
159 SALOME::vectorOfDouble* SALOME_CorbaDoubleNCSender_i::sendPart(CORBA::ULong offset, CORBA::ULong length){
160   SALOME::vectorOfDouble_var c1 = new SALOME::vectorOfDouble(length,length,(CORBA::Double *)((double *)_tabToSend+(long)offset),0);
161   return c1._retn();
162 }
163
164 SALOME::vectorOfDouble* SALOME_CorbaDoubleNCSender_i::send(){
165   SALOME::vectorOfDouble_var c1 = new SALOME::vectorOfDouble(_lgrTabToSend,_lgrTabToSend,(CORBA::Double *)_tabToSend,0);
166   return c1._retn();
167 }
168
169 SALOME_CorbaDoubleCSender_i::SALOME_CorbaDoubleCSender_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend){
170 }
171
172 SALOME_CorbaDoubleCSender_i::~SALOME_CorbaDoubleCSender_i(){
173 }
174
175 CORBA::ULong SALOME_CorbaDoubleCSender_i::getSize(){
176   CORBA::ULong ret=_lgrTabToSend;
177   return ret;
178 }
179
180 SALOME::vectorOfDouble* SALOME_CorbaDoubleCSender_i::sendPart(CORBA::ULong offset, CORBA::ULong length){
181   SALOME::vectorOfDouble_var c1 = new SALOME::vectorOfDouble;
182   c1->length(length);
183   for (long i=0; i<length; i++)
184     c1[i] = ((double *)_tabToSend)[i+offset];
185   return c1._retn();
186 }
187
188 ////////////////////////
189
190 SALOME_CorbaLongNCSender_i::SALOME_CorbaLongNCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend){
191 }
192
193 SALOME_CorbaLongNCSender_i::~SALOME_CorbaLongNCSender_i(){
194 }
195
196 CORBA::ULong SALOME_CorbaLongNCSender_i::getSize(){
197   CORBA::ULong ret=_lgrTabToSend;
198   return ret;
199 }
200
201 SALOME::vectorOfLong* SALOME_CorbaLongNCSender_i::sendPart(CORBA::ULong offset, CORBA::ULong length){
202   SALOME::vectorOfLong_var c1 = new SALOME::vectorOfLong(length,length,(CORBA::Long *)((long *)_tabToSend+(long)offset),0);
203   return c1._retn();
204 }
205
206 SALOME::vectorOfLong* SALOME_CorbaLongNCSender_i::send(){
207   SALOME::vectorOfLong_var c1 = new SALOME::vectorOfLong(_lgrTabToSend,_lgrTabToSend,(CORBA::Long *)_tabToSend,0);
208   return c1._retn();
209 }
210
211 SALOME_CorbaLongCSender_i::SALOME_CorbaLongCSender_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend):SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend){
212 }
213
214 SALOME_CorbaLongCSender_i::~SALOME_CorbaLongCSender_i(){
215 }
216
217 CORBA::ULong SALOME_CorbaLongCSender_i::getSize(){
218   CORBA::ULong ret=_lgrTabToSend;
219   return ret;
220 }
221
222 SALOME::vectorOfLong* SALOME_CorbaLongCSender_i::sendPart(CORBA::ULong offset, CORBA::ULong length){
223   SALOME::vectorOfLong_var c1 = new SALOME::vectorOfLong;
224   c1->length(length);
225   for (long i=0; i<length; i++)
226     c1[i] = ((long *)_tabToSend)[i+offset];
227   return c1._retn();
228 }
229
230 #ifdef HAVE_MPI2
231
232 unsigned long SALOME_MPISender_i::_tag1=0;
233
234 unsigned long SALOME_MPISender_i::_tag2=1;
235
236 SALOME_MPISender_i::SALOME_MPISender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeOf,ownTabToSend){
237   _portName=new char[MPI_MAX_PORT_NAME];
238 }
239
240 SALOME_MPISender_i::~SALOME_MPISender_i(){
241   delete [] _portName;
242 }
243
244 SALOME::MPISender::param* SALOME_MPISender_i::getParam()
245 {
246   char stag[12];
247   int i=0;
248
249   SALOME::MPISender::param_var p = new SALOME::MPISender::param;
250   MPI_Comm_rank(MPI_COMM_WORLD,&_cproc);
251   p->myproc = _cproc;
252   p->tag1 = _tag1;
253   _tag1Inst=_tag1;
254   p->tag2 =_tag2;
255   _tag2Inst=_tag2;
256   std::string service("toto_");
257   sprintf(stag,"%d_",_tag1);
258   service += stag;
259   sprintf(stag,"%d_",p->tag2);
260   service += stag;
261   p->service = CORBA::string_dup(service.c_str());
262   MPI_Open_port(MPI_INFO_NULL, _portName);
263 #if OMPI_MAJOR_VERSION >= 4
264   MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
265 #else
266   MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
267 #endif
268   while ( i != TIMEOUT  && MPI_Publish_name((char*)service.c_str(),MPI_INFO_NULL,_portName) != MPI_SUCCESS) {
269     i++;
270   }
271 #if OMPI_MAJOR_VERSION >= 4
272   MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
273 #else 
274   MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL);
275 #endif
276   if ( i == TIMEOUT  ) { 
277     MPI_Close_port(_portName);
278     MPI_Finalize();
279     exit(-1);
280     }
281   _tag1 += 2;
282   _tag2 += 2;
283   return p._retn();
284 }
285
286 void SALOME_MPISender_i::send()
287 {
288   _type=getTypeOfDataTransmitted();
289   _argsForThr=new void *[8];
290   _argsForThr[0]=_portName;
291   _argsForThr[1]=&_lgrTabToSend;
292   _argsForThr[2]=(void *)_tabToSend;
293   _argsForThr[3]=&_cproc;
294   _argsForThr[4]=&_tag1Inst;
295   _argsForThr[5]=&_tag2Inst;
296   _argsForThr[6]=&_com;
297   _argsForThr[7]=&_type;
298
299   _newThr=new omni_thread(SALOME_MPISender_i::myThread,_argsForThr);
300   _newThr->start();
301 }
302
303 void* SALOME_MPISender_i::myThread(void *args)
304 {
305   void **argsTab=(void **)args;
306   long *lgrTabToSend=(long *)argsTab[1];
307   int *cproc=(int *)argsTab[3];
308   int *tag1=(int *)argsTab[4];
309   int *tag2=(int *)argsTab[5];
310   MPI_Comm *com=(MPI_Comm *)argsTab[6];
311   SALOME::TypeOfDataTransmitted *type=(SALOME::TypeOfDataTransmitted *)argsTab[7];
312
313   MPI_Comm_accept((char *)argsTab[0],MPI_INFO_NULL,0,MPI_COMM_SELF,com);
314   MPI_Send(lgrTabToSend,1,MPI_LONG,*cproc,*tag1,*com);
315   switch(*type)
316     { 
317     case SALOME::DOUBLE_:
318       MPI_Send(argsTab[2],*lgrTabToSend,MPI_DOUBLE,*cproc,*tag2,*com);
319       break;
320     case SALOME::INT_:
321       MPI_Send(argsTab[2],*lgrTabToSend,MPI_INT,*cproc,*tag2,*com);
322     }
323   omni_thread::exit();
324   return args;
325 }
326
327 void SALOME_MPISender_i::close(const SALOME::MPISender::param& p)
328 {
329   std::string service(p.service);
330   void *r;
331   _newThr->join(&r);
332   MPI_Comm_free(&_com); 
333   MPI_Unpublish_name((char *)service.c_str(),MPI_INFO_NULL,_portName); 
334   MPI_Close_port(_portName);
335   delete [] _argsForThr;
336 }
337
338 SALOME_MPISenderDouble_i::SALOME_MPISenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend)
339   :SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_MPISender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend)
340   ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend)
341 {
342 }
343
344 SALOME_MPISenderInt_i::SALOME_MPISenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend)
345   :SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_MPISender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend)
346   ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend)
347 {
348 }
349
350 #endif
351
352 #ifdef HAVE_SOCKET
353
354 //CCRT porting
355 #define _POSIX_PII_SOCKET
356 #define _LIBC_POLLUTION_H_
357
358 #include <sys/types.h>
359 #include <sys/socket.h>
360 #include <netinet/in.h>
361 #include <arpa/inet.h>
362 #include <netdb.h>
363 #include <unistd.h>
364
365 SALOME_SocketSender_i::SALOME_SocketSender_i(const void *tabToSend,long lgrTabToSend,int sizeOf,bool ownTabToSend):SALOME_Sender_i(tabToSend,lgrTabToSend,sizeOf,ownTabToSend){
366   _IPAddress = inetAddress();
367   _serverSockfd = -1;
368   _clientSockfd = -1;
369 }
370
371 SALOME_SocketSender_i::~SALOME_SocketSender_i(){
372 }
373
374 std::string SALOME_SocketSender_i::inetAddress()
375 {
376    char s[256];
377    char t[INET_ADDRSTRLEN+1];
378    struct hostent *host;
379    struct in_addr saddr;
380
381    gethostname(s, 255);
382
383    *t = '\0';
384
385    saddr.s_addr = inet_addr(s);
386    if (saddr.s_addr != -1)
387       inet_ntop(AF_INET, &saddr, t, INET_ADDRSTRLEN);
388    else {
389       host = gethostbyname(s);
390       if (host != NULL)
391          inet_ntop(AF_INET, (struct in_addr *) *host->h_addr_list, 
392                    t, INET_ADDRSTRLEN);
393    }
394    return std::string(t);
395 }
396
397 SALOME::SocketSender::param * SALOME_SocketSender_i::getParam()
398 {
399
400   SALOME::SocketSender::param_var p = new SALOME::SocketSender::param;
401
402   p->lstart = 0;
403   p->lend = _lgrTabToSend - 1;
404   p->myport = _port;
405   p->internet_address = CORBA::string_dup(_IPAddress.c_str());
406
407   return p._retn();
408 }
409
410 void SALOME_SocketSender_i::send()
411 {
412   _type=getTypeOfDataTransmitted();
413   _argsForThr=new void *[6];
414   _argsForThr[0]=&_serverSockfd;
415   _argsForThr[1]=&_clientSockfd;
416   _argsForThr[2]=&_lgrTabToSend;
417   _argsForThr[3]=(void *)_tabToSend;
418   _argsForThr[4]=&_errorFlag;
419   _argsForThr[5]=&_type;
420
421   _newThr=new omni_thread(SALOME_SocketSender_i::myThread,_argsForThr);
422   _newThr->start();
423 }
424
425 void* SALOME_SocketSender_i::myThread(void *args)
426 {
427   int n=0, m;
428   void **argsTab=(void **)args;
429   int *serverSockfd=(int *)argsTab[0];
430   int *clientSockfd=(int *)argsTab[1];
431   long *lgrTabToSend=(long *)argsTab[2];
432   void *tabToSend=argsTab[3];
433   bool *errorFlag=(bool*)argsTab[4];
434   SALOME::TypeOfDataTransmitted *type=(SALOME::TypeOfDataTransmitted *)argsTab[5];
435   
436   XDR xp; /* pointeur sur le decodeur XDR */
437   
438   switch(*type)
439     { 
440     case SALOME::DOUBLE_:
441       xdrmem_create(&xp,(char*)tabToSend,(*lgrTabToSend)*sizeof(double),XDR_ENCODE );
442       xdr_vector( &xp, (char*)tabToSend, *lgrTabToSend, sizeof(double), (xdrproc_t)xdr_double );
443
444       *errorFlag = false;
445       while( n < *lgrTabToSend*sizeof(double) ){
446         m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(double)-n);
447         if( m < 0 ){
448           if( *clientSockfd >= 0 ){
449             ::close(*clientSockfd);
450             *clientSockfd = -1;
451           }
452           if( *serverSockfd >= 0 ){
453             ::close(*serverSockfd);
454             *serverSockfd = -1;
455           }
456           *errorFlag = true;
457         }
458         n += m;
459       }
460       xdr_destroy( &xp );
461
462       xdrmem_create(&xp,(char*)tabToSend,(*lgrTabToSend)*sizeof(double),XDR_DECODE );
463       xdr_vector( &xp, (char*)tabToSend, *lgrTabToSend, sizeof(double), (xdrproc_t)xdr_double );
464       xdr_destroy( &xp );
465       break;
466     case SALOME::INT_:
467       xdrmem_create(&xp,(char*)tabToSend,(*lgrTabToSend)*sizeof(int),XDR_ENCODE );
468       xdr_vector( &xp, (char*)tabToSend, *lgrTabToSend, sizeof(int), (xdrproc_t)xdr_int );
469
470       *errorFlag = false;
471       while( n < *lgrTabToSend*sizeof(int) ){
472         m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(int)-n);
473         if( m < 0 ){
474           if( *clientSockfd >= 0 ){
475             ::close(*clientSockfd);
476             *clientSockfd = -1;
477           }
478           if( *serverSockfd >= 0 ){
479             ::close(*serverSockfd);
480             *serverSockfd = -1;
481           }
482           *errorFlag = true;
483         }
484         n += m;
485       }
486       xdr_destroy( &xp );
487
488       xdrmem_create(&xp,(char*)tabToSend,(*lgrTabToSend)*sizeof(int),XDR_DECODE );
489       xdr_vector( &xp, (char*)tabToSend, *lgrTabToSend, sizeof(int), (xdrproc_t)xdr_int );
490       xdr_destroy( &xp );
491     }
492   return args;
493 }
494
495 void SALOME_SocketSender_i::initCom() throw(SALOME::SALOME_Exception)
496 {
497   struct sockaddr_in serv_addr;
498   socklen_t n;
499   SALOME::ExceptionStruct es;
500
501   /* Ouverture de la socket */
502   _serverSockfd = socket(AF_INET , SOCK_STREAM , 0);
503   if(_serverSockfd < 0) {
504     es.type = SALOME::COMM;
505     es.text = "error Socket exception";
506     throw SALOME::SALOME_Exception(es);
507   }
508   /* Socket structure initialisation*/
509   bzero((char*)&serv_addr,sizeof(serv_addr));
510   serv_addr.sin_family = AF_INET;
511   serv_addr.sin_port = 0; /* asking for a free port */
512   serv_addr.sin_addr.s_addr = INADDR_ANY;
513
514   /* Association of socket with a port */
515   if( ::bind(_serverSockfd, (struct sockaddr *) & serv_addr, 
516            sizeof(struct sockaddr)) < 0 ) {
517     closeCom();
518     es.type = SALOME::COMM;
519     es.text = "error bind Socket exception";
520     throw SALOME::SALOME_Exception(es);
521   }
522   /* Listening to the allocated port */
523   if( listen(_serverSockfd, 10) < 0 ) {
524     closeCom();
525     es.type = SALOME::COMM;
526     es.text = "error listen Socket exception";
527     throw SALOME::SALOME_Exception(es);
528   }
529   /* Retrieving port number*/
530   if( getsockname(_serverSockfd, (struct sockaddr *) & serv_addr, &n) < 0 ){
531     closeCom();
532     es.type = SALOME::COMM;
533     es.text = "error getName Socket exception";
534     throw SALOME::SALOME_Exception(es);
535   }
536   _port = htons(serv_addr.sin_port);
537   SCRUTE(_port);
538 }
539
540 void SALOME_SocketSender_i::acceptCom() throw(SALOME::SALOME_Exception)
541 {
542   socklen_t sin_size;
543   struct sockaddr_in client_addr;
544   SALOME::ExceptionStruct es;
545
546   sin_size = sizeof(struct sockaddr_in);
547   
548   _clientSockfd = accept(_serverSockfd, (struct sockaddr *)&client_addr, &sin_size);
549   if( _clientSockfd < 0 ){
550     closeCom();
551     es.type = SALOME::COMM;
552     es.text = "error accept Socket exception";
553     throw SALOME::SALOME_Exception(es);
554   }
555 }
556
557 void SALOME_SocketSender_i::closeCom()
558 {
559   if( _clientSockfd >= 0 ){
560     ::close(_clientSockfd);
561     _clientSockfd = -1;
562   }
563   if( _serverSockfd >= 0 ){
564     ::close(_serverSockfd);
565     _serverSockfd = -1;
566   }
567
568 }
569
570 void SALOME_SocketSender_i::endOfCom()
571 {
572   void *r;
573   _newThr->join(&r);
574   if(_errorFlag)
575     {
576       SALOME::ExceptionStruct es;
577       es.type = SALOME::COMM;
578       es.text = "error write Socket exception";
579       throw SALOME::SALOME_Exception(es);
580     }
581   delete [] _argsForThr;
582 }
583
584 SALOME_SocketSenderDouble_i::SALOME_SocketSenderDouble_i(const double *tabToSend,long lgrTabToSend,bool ownTabToSend)
585   :SALOME_SenderDouble_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_SocketSender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend)
586   ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(double),ownTabToSend)
587 {
588 }
589
590 SALOME_SocketSenderInt_i::SALOME_SocketSenderInt_i(const int *tabToSend,long lgrTabToSend,bool ownTabToSend)
591   :SALOME_SenderInt_i(tabToSend,lgrTabToSend,ownTabToSend),SALOME_SocketSender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend)
592   ,SALOME_Sender_i(tabToSend,lgrTabToSend,sizeof(int),ownTabToSend)
593 {
594 }
595
596 //CCRT porting
597 #undef _LIBC_POLLUTION_H_
598 #undef _POSIX_PII_SOCKET
599
600 #endif