Include winsock2.h on Windows.

This makes socket code build successfully on Windows.
This commit is contained in:
Jeroen Vermeulen 2015-04-18 00:59:40 +07:00
parent abfdb61bc9
commit 4647986a12
2 changed files with 15 additions and 5 deletions

View File

@ -3,13 +3,13 @@
#include <cstring>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include "Remote.h"
#include "moses/Factor.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include <arpa/inet.h>
#endif
namespace Moses
{
@ -42,7 +42,11 @@ bool LanguageModelRemote::start(const std::string& host, int port)
sock = socket(AF_INET, SOCK_STREAM, 0);
hp = gethostbyname(host.c_str());
if (hp==NULL) {
#if defined(_WIN32) || defined(_WIN64)
fprintf(stderr, "gethostbyname failed\n");
#else
herror("gethostbyname failed");
#endif
exit(1);
}

View File

@ -4,9 +4,15 @@
#include "SingleFactor.h"
#include "moses/TypeDef.h"
#include "moses/Factor.h"
#include <sys/socket.h>
#include <sys/types.h>
#if defined(_WIN32) || defined(_WIN64)
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
namespace Moses
{