From 9920d82a036803e80926e2acfdee92350163c285 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Sat, 19 Mar 2011 16:43:05 +0000 Subject: [PATCH] linux build fixes for windows port --- include/Network.h | 2 ++ include/os.h | 4 +++- src/network/TCPClient.cxx | 14 +++++++++++--- src/network/TCPServer.cxx | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/Network.h b/include/Network.h index 487d2fe6..7a3fadf3 100644 --- a/include/Network.h +++ b/include/Network.h @@ -130,7 +130,9 @@ class UDPClient : public NetworkClient{ struct PacketHeader; class TCPClient : public NetworkClient{ public: +#ifdef WINNT WSADATA wsaData; +#endif int sockfd; struct sockaddr_in srvAddr; ResponsePacket *respPkt; diff --git a/include/os.h b/include/os.h index 6f1a407b..c2c3d294 100644 --- a/include/os.h +++ b/include/os.h @@ -49,6 +49,7 @@ #define DllExport typedef void (*sighandler_t)(int); #define LHANDLE void* +#define LENGTH socklen_t #include #include @@ -179,6 +180,7 @@ typedef size_t socklen_t; #define MS_SYNC 0 #define O_SYNC 0 #define O_DIRECT 0 +#define LENGTH int #define LHANDLE HMODULE #ifndef APP_BUILD #define DllExport __declspec( dllexport ) @@ -290,7 +292,7 @@ class DllExport os static int fdatasync(file_desc fd); static int atexit(void (*exitHndlr)(void)); static void* dlsym(LHANDLE hdl, char* funcName); - static char getopt(int argc, char *argv[], char *opt); + static char getopt(int argc, char *argv[], char *opt); }; #endif diff --git a/src/network/TCPClient.cxx b/src/network/TCPClient.cxx index 4e507f82..17485231 100644 --- a/src/network/TCPClient.cxx +++ b/src/network/TCPClient.cxx @@ -177,12 +177,14 @@ DbRetVal TCPClient::connect() printDebug(DM_Network, "NW:TCP connect %s %d %d\n", hostName, port, networkid); //TODO::send endian to the peer site //do not do endian conversion here. it will be done at the server side +#ifdef WINNT int iResult=0; iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { printf("WSAStartup failed: %d\n", iResult); return ErrSysInit; } +#endif isConnectedFlag = false; struct hostent *he; int numbytes; @@ -243,13 +245,17 @@ DbRetVal TCPClient::disconnect() if (errno == EPIPE) { printError(ErrNoConnection, "connection not present"); os::closeSocket(sockfd); - WSACleanup(); +#ifdef WINNT + WSACleanup(); +#endif isConnectedFlag = false; return ErrNoConnection; } printError(ErrOS, "Unable to send the packet"); os::closeSocket(sockfd); - WSACleanup(); +#ifdef WINNT + WSACleanup(); +#endif sockfd = -1; isConnectedFlag = false; return ErrNoConnection; @@ -258,7 +264,9 @@ DbRetVal TCPClient::disconnect() DbRetVal rv = receive(); isConnectedFlag = false; os::closeSocket(sockfd); - WSACleanup(); +#ifdef WINNT + WSACleanup(); +#endif sockfd = -1; } } diff --git a/src/network/TCPServer.cxx b/src/network/TCPServer.cxx index 126d8e16..543d86b6 100644 --- a/src/network/TCPServer.cxx +++ b/src/network/TCPServer.cxx @@ -67,7 +67,7 @@ DbRetVal TCPServer::handleClient() printf("DEBUG::handling client\n"); DbRetVal rv = OK; socklen_t addressLen = sizeof(struct sockaddr); - clientfd = accept(sockfd, (struct sockaddr*) &clientAddress, (int*)&addressLen); + clientfd = accept(sockfd, (struct sockaddr*) &clientAddress, (LENGTH*)&addressLen); int ret = os::fork(); if (ret) { //parent -- 2.11.4.GIT