]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/input_output/FGfdmSocket.cpp
Clean up header file use of iostream and "using" declarations
[flightgear.git] / src / FDM / JSBSim / input_output / FGfdmSocket.cpp
index c9db20f9486d9e7fc62169ae7e635c1a9b5261e6..2376f2b806f28c3c8d28962e1ab373c20bdd40b5 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 FUNCTIONAL DESCRIPTION
@@ -37,6 +37,9 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <cstring>
+#include <iostream>
+
 #include "FGfdmSocket.h"
 
 namespace JSBSim {
@@ -44,6 +47,10 @@ namespace JSBSim {
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_FDMSOCKET;
 
+using std::cerr;
+using std::cout;
+using std::endl;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -79,16 +86,16 @@ FGfdmSocket::FGfdmSocket(string address, int port)
       memset(&scktName, 0, sizeof(struct sockaddr_in));
       scktName.sin_family = AF_INET;
       scktName.sin_port = htons(port);
-      memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
+      std::memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
       int len = sizeof(struct sockaddr_in);
       if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
-        cout << "Successfully connected to socket ..." << endl;
+        cout << "Successfully connected to socket for output ..." << endl;
         connected = true;
       } else {                // unsuccessful
-        cout << "Could not connect to socket ..." << endl;
+        cout << "Could not connect to socket for output ..." << endl;
       }
     } else {          // unsuccessful
-      cout << "Could not create socket for FDM, error = " << errno << endl;
+      cout << "Could not create socket for FDM output, error = " << errno << endl;
     }
   }
   Debug(0);
@@ -113,13 +120,12 @@ FGfdmSocket::FGfdmSocket(int port)
   sckt = socket(AF_INET, SOCK_STREAM, 0);
 
   if (sckt >= 0) {  // successful
-    memset(&scktName, 0, sizeof(struct sockaddr_in));
+    std::memset(&scktName, 0, sizeof(struct sockaddr_in));
     scktName.sin_family = AF_INET;
     scktName.sin_port = htons(port);
-//    memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
     int len = sizeof(struct sockaddr_in);
     if (bind(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
-      cout << "Successfully bound to socket ..." << endl;
+      cout << "Successfully bound to socket for input on port " << port << endl;
       if (listen(sckt, 5) >= 0) { // successful listen()
         #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
           ioctlsocket(sckt, FIONBIO, &NoBlock);
@@ -133,10 +139,10 @@ FGfdmSocket::FGfdmSocket(int port)
       }
       connected = true;
     } else {                // unsuccessful
-      cerr << "Could not bind to socket ..." << endl;
+      cerr << "Could not bind to socket for input ..." << endl;
     }
   } else {          // unsuccessful
-    cerr << "Could not create socket for FDM, error = " << errno << endl;
+    cerr << "Could not create socket for FDM input, error = " << errno << endl;
   }
 
   Debug(0);