add windows websockets client support

This commit is contained in:
QingGo 2020-09-15 20:54:33 +08:00
parent 981d5d4e99
commit d627b85202
2 changed files with 7 additions and 4 deletions

View file

@ -7,7 +7,11 @@
#include "base/system.h"
#include "protocol.h"
#include "ringbuffer.h"
#if defined(CONF_FAMILY_UNIX)
#include <arpa/inet.h>
#elif defined(CONF_FAMILY_WINDOWS)
#include <Ws2tcpip.h>
#endif
#include <libwebsockets.h>
extern "C" {

View file

@ -1,12 +1,11 @@
#ifndef ENGINE_SHARED_WEBSOCKETS_H
#define ENGINE_SHARED_WEBSOCKETS_H
#if !defined(CONF_FAMILY_UNIX)
#error websockets only work on unix, sorry
#if defined(CONF_FAMILY_UNIX)
#elif defined(CONF_FAMILY_WINDOWS)
#include <winsock2.h>
#endif
#include <netinet/in.h>
int websocket_create(const char *addr, int port);
int websocket_destroy(int socket);
int websocket_recv(int socket, unsigned char *data, size_t maxsize, struct sockaddr_in *sockaddrbuf, size_t fromLen);