From 2b9f068e7ee4c0d249c715f9eb5a3c2c8a11e6f8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 26 Mar 2008 18:10:17 +0000 Subject: win32 updates --- src/core/application.cc | 5 +++++ src/core/netclient.h | 4 ++++ src/core/netconnection.cc | 6 +++++- src/core/netconnection.h | 4 ++++ src/core/netserver.cc | 19 ++++++++++++++++--- src/core/netserver.h | 4 ++++ 6 files changed, 38 insertions(+), 4 deletions(-) (limited to 'src/core') 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 #include +#ifndef _WIN32 #include #include #include #include #include +#else +#include +#endif #include #include 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 #include +#ifndef _WIN32 #include #include #include @@ -19,6 +20,9 @@ #include #include +#else +#include +#endif #include #include 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 #include +#ifndef _WIN32 #include #include #include #include #include +#else +#include +#endif #include #include @@ -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 +#else +#include +#endif #include #include -- cgit v1.2.3