[DEV] start port of windows socket

This commit is contained in:
Edouard DUPIN 2016-09-28 21:52:50 +02:00
parent 739f70020b
commit 1571338fde
6 changed files with 27 additions and 15 deletions

View File

@ -7,14 +7,17 @@
#include <enet/debug.h>
#include <enet/Tcp.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <etk/stdTools.h>
#ifndef __TARGET_OS__Windows
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#endif
bool enet::Tcp::setTCPNoDelay(bool _enabled) {
if (m_socketId >= 0) {

View File

@ -6,14 +6,18 @@
#pragma once
#include <etk/types.h>
#include <poll.h>
#include <mutex>
#ifndef __TARGET_OS__Windows
#include <poll.h>
#endif
namespace enet {
class Tcp {
private:
int32_t m_socketId; //!< socket linux interface generic
#ifndef __TARGET_OS__Windows
struct pollfd m_fds[1];
#endif
std::mutex m_mutex;
public:
Tcp();

View File

@ -8,13 +8,13 @@
#include <enet/Tcp.h>
#include <enet/TcpClient.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <etk/stdTools.h>
#include <sys/socket.h>
enet::Tcp enet::connectTcpClient(uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8_t _ip4, uint16_t _port, uint32_t _numberRetry) {

View File

@ -8,14 +8,20 @@
#include <enet/Tcp.h>
#include <enet/TcpServer.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <etk/stdTools.h>
#ifdef __TARGET_OS__Windows
#include <winsock2.h>
//https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms737889(v=vs.85).aspx
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#endif
enet::TcpServer::TcpServer() :
m_socketId(-1),

View File

@ -4,15 +4,18 @@
* @license APACHE v2.0 (see license file)
*/
#pragma once
#include <poll.h>
#include <enet/Tcp.h>
#ifdef __TARGET_OS__Windows
#else
#include <poll.h>
#endif
namespace enet {
class TcpServer {
private:
int32_t m_socketId; //!< socket linux interface generic
#if 1
#ifndef __TARGET_OS__Windows
struct pollfd m_fds[1];
#endif
public:

View File

@ -31,13 +31,9 @@ def create(target, module_name):
'ememory',
'algue'
])
my_module.add_src_file([
'enet/debug.cpp'
])
my_module.add_path(tools.get_current_path(__file__))
if "Windows" in target.get_type():
return my_module
my_module.add_src_file([
'enet/debug.cpp',
'enet/Udp.cpp',
'enet/Tcp.cpp',
'enet/TcpServer.cpp',