Skip to content

Commit

Permalink
Merge pull request #46 from MissouriMRDT/hotfix/windows-native-build
Browse files Browse the repository at this point in the history
Make Native Windows Builds Possible
  • Loading branch information
ClayJay3 authored Oct 30, 2024
2 parents 2505b73 + 244928a commit 92844aa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/RoveComm/RoveCommGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <cstring>
#include <functional>
#include <iostream>
#include <unistd.h>
#include <vector>

/// \endcond
Expand Down
2 changes: 2 additions & 0 deletions src/RoveComm/RoveCommPacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <vector>

#if defined(__ROVECOMM_WINDOWS_MODE__) && __ROVECOMM_WINDOWS_MODE__ == 1
typedef int ssize_t;
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
#elif _WIN32_WINNT < 0x0600
Expand All @@ -28,6 +29,7 @@
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#else
#include <arpa/inet.h>
#include <fcntl.h>
Expand Down
12 changes: 6 additions & 6 deletions src/RoveComm/RoveCommTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ namespace rovecomm
if (bind(m_nTCPSocket.load(), (struct sockaddr*) &m_saTCPServerAddr, sizeof(m_saTCPServerAddr)) == -1)
{
perror("Failed to bind TCP socket");
close(m_nTCPSocket);
CLOSE_SOCKET(m_nTCPSocket);
return false;
}

// Listen for incoming connections
if (listen(m_nTCPSocket, 5) == -1)
{
perror("Failed to listen on TCP socket");
close(m_nTCPSocket);
CLOSE_SOCKET(m_nTCPSocket);
return false;
}

Expand Down Expand Up @@ -178,15 +178,15 @@ namespace rovecomm
if (inet_pton(AF_INET, cClientIPAddress, &saClientAddr.sin_addr) <= 0)
{
perror("Invalid address/ Address not supported");
close(nClientSocket);
CLOSE_SOCKET(nClientSocket);
return -1;
}

// Connect to the client
if (connect(nClientSocket, (struct sockaddr*) &saClientAddr, sizeof(saClientAddr)) == -1)
{
perror("Connection failed");
close(nClientSocket);
CLOSE_SOCKET(nClientSocket);
return -1;
}

Expand All @@ -209,7 +209,7 @@ namespace rovecomm
}

// Close the client socket
close(nClientSocket);
CLOSE_SOCKET(nClientSocket);

return siBytesSent;
}
Expand Down Expand Up @@ -483,7 +483,7 @@ namespace rovecomm
}

// Close the client socket
close(m_nCurrentTCPClientSocket);
CLOSE_SOCKET(m_nCurrentTCPClientSocket);
m_nCurrentTCPClientSocket = -1;
}
// Still waiting for data or connection return without error.
Expand Down
1 change: 0 additions & 1 deletion src/RoveComm/RoveCommTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <functional>
#include <iostream>
#include <shared_mutex>
#include <unistd.h>
#include <vector>

/// \endcond
Expand Down
2 changes: 1 addition & 1 deletion src/RoveComm/RoveCommUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ namespace rovecomm
if (bind(m_nUDPSocket.load(), (struct sockaddr*) &saServerAddr, sizeof(saServerAddr)) == -1)
{
perror("Failed to bind UDP socket");
close(m_nUDPSocket);
CLOSE_SOCKET(m_nUDPSocket);
return false;
}

Expand Down
1 change: 0 additions & 1 deletion src/RoveComm/RoveCommUDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <functional>
#include <iostream>
#include <shared_mutex>
#include <unistd.h>
#include <unordered_set>
#include <vector>

Expand Down

0 comments on commit 92844aa

Please sign in to comment.