Skip to content
Snippets Groups Projects
Commit fc35a765 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Get msgpack working in Windows and fix network code to compile in windows.

parent 3193825b
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ find_package( glog REQUIRED )
find_package( OpenCV REQUIRED )
find_package( Threads REQUIRED )
find_package( URIParser REQUIRED )
find_package( MsgPack )
find_package( MsgPack REQUIRED )
find_package( LibSGM )
check_language(CUDA)
......@@ -35,6 +35,14 @@ if (NOT MsgPack_FOUND)
message(ERROR "Msgpack is required")
endif()
else()
if(WIN32)
# Find include
find_path(MSGPACK_INCLUDE_DIRS
NAMES msgpack.hpp
PATHS "C:/Program Files/msgpack" "C:/Program Files (x86)/msgpack"
PATH_SUFFIXES include
)
endif()
include_directories(${MSGPACK_INCLUDE_DIRS})
endif()
......
......@@ -7,7 +7,7 @@
#ifdef WIN32
//#include <windows.h>
#include <winsock.h>
#include <winsock2.h>
#endif
#include <ftl/net/handlers.hpp>
......
#ifndef _FTL_NET_SOCKET_HPP_
#define _FTL_NET_SOCKET_HPP_
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <glog/logging.h>
#include <ftl/net.hpp>
#include <ftl/net/protocol.hpp>
......@@ -12,7 +13,8 @@
#ifdef WIN32
//#include <windows.h>
#include <winsock.h>
//#include <winsock.h>
#include <winsock2.h>
#endif
#include <iostream>
......
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <glog/logging.h>
#include <ftl/net/dispatcher.hpp>
#include <ftl/net/socket.hpp>
......
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <glog/logging.h>
#include <ftl/uri.hpp>
......@@ -27,6 +28,7 @@ typedef int socklen_t;
using namespace ftl;
using ftl::net::Listener;
using std::shared_ptr;
using ftl::net::Socket;
int tcpListen(URI &uri) {
int ssock;
......@@ -45,7 +47,7 @@ int tcpListen(URI &uri) {
}
int enable = 1;
if (setsockopt(ssock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0)
if (setsockopt(ssock, SOL_SOCKET, SO_REUSEADDR, (char*)(&enable), sizeof(int)) < 0)
LOG(ERROR) << "setsockopt(SO_REUSEADDR) failed";
//Specify listen port and address
......
......@@ -2,6 +2,10 @@
#include <ftl/net/listener.hpp>
#include <ftl/net/socket.hpp>
#ifdef WIN32
#include <Ws2tcpip.h>
#endif
#include <vector>
#include <iostream>
#include <chrono>
......@@ -135,6 +139,7 @@ bool _run(bool blocking, bool nodelay) {
if (FD_ISSET(l->_socket(), &sfdread)) {
int rsize = sizeof(sockaddr_storage);
sockaddr_storage addr;
//int freeclient = freeSocket();
//if (freeclient >= 0) {
......
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <glog/logging.h>
#include <ftl/net/socket.hpp>
#include <ftl/net/protocol.hpp>
......
#define GLOG_NO_ABBREVIATED_SEVERITIES
#include <glog/logging.h>
#include <ftl/uri.hpp>
......@@ -16,9 +17,8 @@
#ifdef WIN32
#include <windows.h>
#include <winsock.h>
typedef int socklen_t;
#define MSG_WAITALL 0
#include <winsock2.h>
#include <Ws2tcpip.h>
#endif
#include <iostream>
......@@ -27,6 +27,7 @@ typedef int socklen_t;
using namespace ftl;
using ftl::net::Socket;
using ftl::net::Protocol;
using namespace std;
/*static std::string hexStr(const std::string &s)
......@@ -233,8 +234,12 @@ void Socket::setProtocol(Protocol *p) {
void Socket::error() {
int err;
#ifdef WIN32
int optlen = sizeof(err);
#else
uint32_t optlen = sizeof(err);
getsockopt(sock_, SOL_SOCKET, SO_ERROR, &err, &optlen);
#endif
getsockopt(sock_, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen);
LOG(ERROR) << "Socket: " << uri_ << " - error " << err;
}
......@@ -390,7 +395,15 @@ void Socket::_connected() {
}
int Socket::_send() {
#ifdef WIN32
// TODO(nick) Use WSASend instead
int c = 0;
for (auto v : send_vec_) {
c += ::send(sock_, (char*)v.iov_base, v.iov_len, 0);
}
#else
int c = ::writev(sock_, send_vec_.data(), send_vec_.size());
#endif
send_vec_.clear();
return c;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment