Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Windows Compatibility #1

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 13 additions & 7 deletions Essentials/pShare/Listener.cpp
Expand Up @@ -5,12 +5,18 @@
* Author: pnewman
*/
#ifndef _WIN32
#include "unistd.h"
#include "unistd.h"
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h> //for ip_mreq
#include "winbase.h"
#include "winnt.h"
#include "windows.h"
#endif

#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>
#include <cstring>
#include <stdexcept>
Expand Down Expand Up @@ -52,7 +58,7 @@ bool Listener::ListenLoop()

//we want to be able to resuse it (multiple folk are interested)
int reuse = 1;
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, &reuse, sizeof(reuse)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET,SO_REUSEADDR/* SO_REUSEPORT*/, (const char*)&reuse, sizeof(reuse)) == -1)
throw std::runtime_error("Listener::ListenLoop::setsockopt::reuse");

/* if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT,
Expand All @@ -63,7 +69,7 @@ bool Listener::ListenLoop()
//give ourselves plenty of receive space
//set aside some space for receiving - just a few multiples of 64K
int rx_buffer_size = 64*1024*28;
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, &rx_buffer_size, sizeof(rx_buffer_size)) == -1)
if (setsockopt(socket_fd, SOL_SOCKET, SO_RCVBUF, (const char*)&rx_buffer_size, sizeof(rx_buffer_size)) == -1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::rcvbuf");


Expand Down Expand Up @@ -91,7 +97,7 @@ bool Listener::ListenLoop()
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(address_.host().c_str());
mreq.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))==-1)
if(setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&mreq, sizeof(mreq))==-1)
throw std::runtime_error("Listener::ListenLoop()::setsockopt::ADD_MEMBERSHIP");
}

Expand Down