-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Module: FGfdmSocket.cpp
Author: Jon S. Berndt
--------------------------------------------------------------------------------
11/08/99 JSB Created
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGfdmSocket.h"
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_FDMSOCKET;
+
+extern short debug_lvl;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGfdmSocket::FGfdmSocket(string address, int port)
{
size = 0;
- #if defined( __BORLANDC__ ) || defined( _MSC_VER )
+ #if defined(__BORLANDC__) || defined(_MSC_VER)
WSADATA wsaData;
int PASCAL FAR wsaReturnCode;
wsaReturnCode = WSAStartup(MAKEWORD(1,1), &wsaData);
cout << "Could not create socket for FDM, error = " << errno << endl;
}
}
+
+ if (debug_lvl & 2) cout << "Instantiated: FGfdmSocket" << endl;
}
-#ifdef MACOS
-/* commented out destructor method. shutdown method needs to link when
- we don't have networking enabled */
-#else
-FGfdmSocket::~FGfdmSocket(void)
+FGfdmSocket::~FGfdmSocket()
{
+ #ifndef macintosh
if (sckt) shutdown(sckt,2);
+ #endif
+
#ifdef __BORLANDC__
WSACleanup();
#endif
}
-#endif
void FGfdmSocket::Clear(void)
{
void FGfdmSocket::Send(void)
{
- int len;
-
buffer += string("\n");
- if ((len = send(sckt,buffer.c_str(),buffer.size(),0)) <= 0) {
+ if ((send(sckt,buffer.c_str(),buffer.size(),0)) <= 0) {
perror("send");
} else {
}