certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi CMakeLists.txt libCERTI/SocketUN.hh libCE...


From: certi-cvs
Subject: [certi-cvs] certi CMakeLists.txt libCERTI/SocketUN.hh libCE...
Date: Wed, 18 Jun 2008 11:14:25 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Eric NOULARD <erk>      08/06/18 11:14:25

Modified files:
        .              : CMakeLists.txt 
        libCERTI       : SocketUN.hh SocketUN.cc 

Log message:
        Add option in order to use TCP socket for
        RTIA<-->Federate communication on Unix platform.
        One should use the RTIA_USE_TCP option with CMake

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/CMakeLists.txt?cvsroot=certi&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketUN.hh?cvsroot=certi&r1=3.13&r2=3.14
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketUN.cc?cvsroot=certi&r1=3.20&r2=3.21

Patches:
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/CMakeLists.txt,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- CMakeLists.txt      7 May 2008 14:10:29 -0000       1.46
+++ CMakeLists.txt      18 Jun 2008 11:14:24 -0000      1.47
@@ -31,7 +31,19 @@
 OPTION(FORCE_NO_X11 
               "Force not to use X11 (i.e. no Billard GUI)" OFF)    
 
+# On Win32 platform RTIA must use TCP Socket for RTIA <-->FedAmbd
+# On other platform TCP socket is an option               
+IF(WIN32)
+    SET(RTIA_USE_TCP ON)
+ELSE(WIN32)
+    OPTION(RTIA_USE_TCP 
+           "Force TCP socket usage between RTIA and FederateAmbassador 
(default is Unix Socket)" OFF)
+ENDIF(WIN32) 
+
 SET(CMAKE_BUILD_TYPE "Debug")
+IF(RTIA_USE_TCP) 
+    ADD_DEFINITIONS(-DRTIA_USE_TCP)
+ENDIF(RTIA_USE_TCP)
 
 # Force CMAKE_COMPILER_IS_GNUCC even if gcc used with ccache
 IF("${CMAKE_C_COMPILER}" MATCHES "ccache")

Index: libCERTI/SocketUN.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketUN.hh,v
retrieving revision 3.13
retrieving revision 3.14
diff -u -b -r3.13 -r3.14
--- libCERTI/SocketUN.hh        27 Nov 2007 08:55:54 -0000      3.13
+++ libCERTI/SocketUN.hh        18 Jun 2008 11:14:24 -0000      3.14
@@ -20,7 +20,7 @@
 #ifndef CERTI_SOCKET_UN_HH
 #define CERTI_SOCKET_UN_HH
 
-#ifdef _WIN32
+#if defined(RTIA_USE_TCP)
        #include "SocketTCP.hh"
 #else
        #include <netdb.h>

Index: libCERTI/SocketUN.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketUN.cc,v
retrieving revision 3.20
retrieving revision 3.21
diff -u -b -r3.20 -r3.21
--- libCERTI/SocketUN.cc        3 Apr 2008 15:21:52 -0000       3.20
+++ libCERTI/SocketUN.cc        18 Jun 2008 11:14:24 -0000      3.21
@@ -23,8 +23,12 @@
 #include "SocketUN.hh"
 #include "baseTypes.hh"
 
-#ifdef _WIN32
+#if defined(RTIA_USE_TCP)
 #include "SocketTCP.hh"
+#if not defined(_WIN32)
+#include <cstring>
+#include <cerrno>
+#endif
 #else
 #include <unistd.h>
 #include <strings.h>
@@ -52,12 +56,15 @@
 void
 SocketUN::acceptUN()
 {
-#ifdef _WIN32
+#if defined(RTIA_USE_TCP)
        struct sockaddr_in nom_client, nom_serveur;
        int lg_nom;
        int result;
+       socklen_t socklen;
 
+#if defined(_WIN32)
        assert(SocketTCP::winsockInitialized());
+#endif
 
        if((sock_connect=socket(AF_INET,SOCK_STREAM,0)) < 0)
                error("socket");
@@ -79,17 +86,16 @@
 
        result = ::bind(sock_connect,(sockaddr *)&nom_serveur, lg_nom);
 
-       if((result <0) &&(WSAGetLastError() == WSAEADDRINUSE))
+       if(result <0)
                {// Error on Bind. If the error is "Address already in use", 
allow
                // the user to choose to "reuse address" and then try again.
                error("bind");
                }
-
        pD->Out(pdInit, "Server: Bind succeeded, now listening.");
 #else
 
     struct sockaddr_un nom_client, nom_serveur ;
-    socklen_t lg_nom ;
+    socklen_t socklen ;
 
     pD->Out(pdInit, "Opening Server UNIX Socket.");
 
@@ -131,10 +137,10 @@
 pD->Out(pdInit, "Server: Listen returned, now accepting.");
 
 // Accept
-lg_nom = sizeof(struct sockaddr_in);
+socklen = sizeof(struct sockaddr_in);
 if ((_socket_un = accept(sock_connect,
                        (struct sockaddr*)&nom_client,
-                       &lg_nom)) < 0)
+                       &socklen)) < 0)
   // HPUX:(int*) &lg_nom)) < 0)
   error("accept");
 
@@ -155,11 +161,13 @@
 int Attempt = 0 ;
 int Result = 0 ;
 
-#ifdef _WIN32
+#if defined(RTIA_USE_TCP)
        struct sockaddr_in nom_serveur;
        int lg_nom;
+#ifdef _WIN32
        struct hostent *hptr = NULL;
        assert(SocketTCP::winsockInitialized());
+#endif
 #else
        struct sockaddr_un nom_serveur;
 #endif
@@ -172,8 +180,8 @@
        {
        pD->Out(pdInit, "Opening Client UNIX Socket.");
        
-// Socket--------------------------------------------------
-#ifdef _WIN32
+// TCP Socket case--------------------------------------------------
+#if defined(RTIA_USE_TCP)
        if((_socket_un = socket(AF_INET, SOCK_STREAM, 0)) == -1)
                error("socket");
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]