Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-26 18:10:17 +0000
committerStijn Buys <ingar@osirion.org>2008-03-26 18:10:17 +0000
commit2b9f068e7ee4c0d249c715f9eb5a3c2c8a11e6f8 (patch)
treefcd373f97385dc150437bc09b2143e0ceee589e1 /src/core
parenta29aa1ee2935857f616351a23578311f514516d4 (diff)
win32 updates
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc5
-rw-r--r--src/core/netclient.h4
-rw-r--r--src/core/netconnection.cc6
-rw-r--r--src/core/netconnection.h4
-rw-r--r--src/core/netserver.cc19
-rw-r--r--src/core/netserver.h4
6 files changed, 38 insertions, 4 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index d1dbcc0..485bac2 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -98,6 +98,7 @@ void func_name(std::string const &args) {
extern "C" void signal_handler(int signum)
{
+#ifndef _WIN32
switch (signum) {
case SIGHUP:
case SIGINT:
@@ -117,6 +118,7 @@ extern "C" void signal_handler(int signum)
application()->quit(1);
break;
}
+#endif
}
// --------------- Application -----------------------------
@@ -134,10 +136,13 @@ Application::Application()
application_time = 0;
application_game = 0;
+#ifndef _WIN32
sys::signal(SIGHUP, signal_handler);
sys::signal(SIGINT, signal_handler);
sys::signal(SIGQUIT, signal_handler);
sys::signal(SIGTERM, signal_handler);
+#endif
+
}
Application::~Application()
diff --git a/src/core/netclient.h b/src/core/netclient.h
index 49f509c..7176260 100644
--- a/src/core/netclient.h
+++ b/src/core/netclient.h
@@ -10,12 +10,16 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#else
+#include <windows.h>
+#endif
#include <string>
#include <deque>
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index b640595..18ae3bc 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -74,8 +74,12 @@ void NetConnection::connect(std::string const &to_host, int to_port)
connection_error = false;
FD_ZERO(&clientset);
+#ifdef _WIN32
+ FD_SET((unsigned int) fd(), &clientset);
+#else
FD_SET(fd(), &clientset);
-
+#endif
+
connection_timeout = application()->time();
connection_keepalive = application()->time();
diff --git a/src/core/netconnection.h b/src/core/netconnection.h
index 08536de..3cc28db 100644
--- a/src/core/netconnection.h
+++ b/src/core/netconnection.h
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -19,6 +20,9 @@
#include <sys/select.h>
#include <netdb.h>
+#else
+#include <windows.h>
+#endif
#include <string>
#include <deque>
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 3b17a65..e3e01a3 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -7,12 +7,16 @@
#include <unistd.h>
#include <errno.h>
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#else
+#include <windows.h>
+#endif
#include <iostream>
#include <sstream>
@@ -25,6 +29,10 @@
#include "core/func.h"
#include "core/core.h"
+#ifdef _WIN32
+ typedef int socklen_t;
+#endif
+
namespace core
{
@@ -43,7 +51,8 @@ NetServer::NetServer(std::string const host, unsigned int const port)
//perror("socket");
return;
}
-
+
+ /*
// set socket options
socklen_t yes = 1;
if (::setsockopt(netserver_fd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(socklen_t)) == -1) {
@@ -51,6 +60,7 @@ NetServer::NetServer(std::string const host, unsigned int const port)
//perror("setsockopt");
return;
}
+ */
// Get the local adress to bind to
netserver_addr.sin_family = AF_INET;
@@ -77,8 +87,11 @@ NetServer::NetServer(std::string const host, unsigned int const port)
// add the listening socket to the file descriptor set
FD_ZERO(&serverset);
+#ifdef _WIN32
+ FD_SET((unsigned int) netserver_fd, &serverset);
+#else
FD_SET(netserver_fd, &serverset);
-
+#endif
netserver_error = false;
}
@@ -173,7 +186,7 @@ void NetServer::receive()
while (nb && FD_ISSET(fd(), &readset)) {
// receive incoming data
- struct sockaddr_in client_addr;
+ struct sockaddr_in client_addr;
socklen_t client_addr_len = sizeof(client_addr);
memset(recbuf, '\0', sizeof(recbuf));
ssize_t bytes_received = ::recvfrom(fd(), recbuf, FRAMESIZE-1, 0, (struct sockaddr *)&client_addr, &client_addr_len);
diff --git a/src/core/netserver.h b/src/core/netserver.h
index de923b9..5850b29 100644
--- a/src/core/netserver.h
+++ b/src/core/netserver.h
@@ -7,7 +7,11 @@
#ifndef __INCLUDED_CORE_NETSERVER_H__
#define __INCLUDED_CORE_NETSERVER_H__
+#ifndef _WIN32
#include <sys/select.h>
+#else
+#include <windows.h>
+#endif
#include <list>
#include <string>