# Add helper files for Windows.
if (WIN32)
set(WIN32_HELPERS_PATH win32port/win32helpers)
-
- list(APPEND HDR_PUBLIC
- ${WIN32_HELPERS_PATH}/websock-w32.h
- )
include_directories(${WIN32_HELPERS_PATH})
else(WIN32)
# Unix.
#
# Helper function for adding a test app.
#
- macro(create_test_app TEST_NAME MAIN_SRC WIN32_SRCS WIN32_HDRS)
+ macro(create_test_app TEST_NAME MAIN_SRC)
set(TEST_SRCS ${MAIN_SRC})
set(TEST_HDR)
${WIN32_HELPERS_PATH}/getopt.c
${WIN32_HELPERS_PATH}/getopt_long.c
${WIN32_HELPERS_PATH}/gettimeofday.c
- ${WIN32_SRCS})
+ )
list(APPEND TEST_HDR
${WIN32_HELPERS_PATH}/getopt.h
${WIN32_HELPERS_PATH}/gettimeofday.h
- ${WIN32_HDRS})
+ )
endif(WIN32)
source_group("Headers Private" FILES ${TEST_HDR})
# test-server
#
if (NOT LWS_WITHOUT_TEST_SERVER)
- create_test_app(test-server
- "test-server/test-server.c"
- ""
- "${WIN32_HELPERS_PATH}/websock-w32.h")
+ create_test_app(test-server "test-server/test-server.c")
endif()
#
# test-server-extpoll
#
if (NOT LWS_WITHOUT_TEST_SERVER_EXTPOLL)
- create_test_app(test-server-extpoll
- "test-server/test-server.c"
- ""
- "${WIN32_HELPERS_PATH}/websock-w32.h")
+ create_test_app(test-server-extpoll "test-server/test-server.c")
# Set defines for this executable only.
set_property(
TARGET test-server-extpoll
# test-client
#
if (NOT LWS_WITHOUT_TEST_CLIENT)
- create_test_app(test-client
- "test-server/test-client.c"
- ""
- "")
+ create_test_app(test-client "test-server/test-client.c")
endif()
#
# test-fraggle
#
if (NOT LWS_WITHOUT_TEST_FRAGGLE)
- create_test_app(test-fraggle
- "test-server/test-fraggle.c"
- ""
- "")
+ create_test_app(test-fraggle "test-server/test-fraggle.c")
endif()
#
# test-ping
#
if (NOT LWS_WITHOUT_TEST_PING)
- create_test_app(test-ping
- "test-server/test-ping.c"
- ""
- "")
+ create_test_app(test-ping "test-server/test-ping.c")
endif()
#
# test-echo
#
if (NOT WITHOUT_TEST_ECHO)
- create_test_app(test-echo
- "test-server/test-echo.c"
- ""
- "")
+ create_test_app(test-echo "test-server/test-echo.c")
endif()
endif(NOT LWS_WITHOUT_CLIENT)
struct libwebsocket_context *context,
struct libwebsocket *wsi
) {
- struct pollfd pfd;
+ struct libwebsocket_pollfd pfd;
#ifdef LWS_USE_IPV6
struct sockaddr_in6 server_addr6;
struct sockaddr_in6 client_addr6;
#endif
int lws_client_socket_service(struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd)
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
{
int n;
char *p = (char *)&context->service_buffer[0];
#ifndef LWS_NO_CLIENT
extern int lws_client_socket_service(
struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd);
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
#endif
#ifndef LWS_NO_SERVER
extern int lws_server_socket_service(
struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd);
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
#endif
#ifdef _WIN32
return wsi->sock_send_blocking;
#else
- struct pollfd fds;
+ struct libwebsocket_pollfd fds;
/* treat the fact we got a truncated send pending as if we're choked */
if (wsi->truncated_send_len)
int
lws_handle_POLLOUT_event(struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd)
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
{
int n;
return 0;
}
-static int lws_poll_listen_fd(struct pollfd* fd)
+static int lws_poll_listen_fd(struct libwebsocket_pollfd* fd)
{
#ifdef _WIN32
fd_set readfds;
LWS_VISIBLE int
libwebsocket_service_fd(struct libwebsocket_context *context,
- struct pollfd *pollfd)
+ struct libwebsocket_pollfd *pollfd)
{
struct libwebsocket *wsi;
int n;
LWS_VISIBLE void
libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
- struct pollfd eventfd;
+ struct libwebsocket_pollfd eventfd;
struct lws_io_watcher *lws_io = (struct lws_io_watcher*)watcher;
struct libwebsocket_context *context = lws_io->context;
int i;
DWORD ev;
WSANETWORKEVENTS networkevents;
- struct pollfd *pfd;
+ struct libwebsocket_pollfd *pfd;
#else
int m;
char buf;
struct libwebsocket_context *context = wsi->protocol->owning_server;
int tid;
int sampled_tid;
- struct pollfd *pfd;
+ struct libwebsocket_pollfd *pfd;
struct libwebsocket_pollargs pa;
#ifdef _WIN32
long networkevents = FD_WRITE;
context->max_fds = getdtablesize();
lwsl_notice(" static allocation: %u + (%u x %u fds) = %u bytes\n",
sizeof(struct libwebsocket_context),
- sizeof(struct pollfd) + sizeof(struct libwebsocket *),
+ sizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *),
context->max_fds,
sizeof(struct libwebsocket_context) +
- ((sizeof(struct pollfd) + sizeof(struct libwebsocket *)) *
+ ((sizeof(struct libwebsocket_pollfd) + sizeof(struct libwebsocket *)) *
context->max_fds));
- context->fds = (struct pollfd *)malloc(sizeof(struct pollfd) *
+ context->fds = (struct libwebsocket_pollfd *)malloc(sizeof(struct libwebsocket_pollfd) *
context->max_fds);
if (context->fds == NULL) {
lwsl_err("Unable to allocate fds array for %d connections\n",
#include <ws2tcpip.h>
#include <stddef.h>
#include <basetsd.h>
-#include "websock-w32.h"
#define strcasecmp stricmp
#define getdtablesize() 30000
int prev_events; // the previous event mask
};
+#ifdef _WIN32
+struct libwebsocket_pollfd {
+ SOCKET fd;
+ SHORT events;
+ SHORT revents;
+};
+#else
+#define libwebsocket_pollfd pollfd
+#endif
#ifndef LWS_NO_EXTENSIONS
enum libwebsocket_extension_callback_reasons {
LWS_VISIBLE LWS_EXTERN int
libwebsocket_service_fd(struct libwebsocket_context *context,
- struct pollfd *pollfd);
+ struct libwebsocket_pollfd *pollfd);
LWS_VISIBLE LWS_EXTERN void *
libwebsocket_context_user(struct libwebsocket_context *context);
#define LWS_EWOULDBLOCK WSAEWOULDBLOCK
#define LWS_POLLIN (FD_READ | FD_ACCEPT)
#define LWS_POLLOUT (FD_WRITE)
+#define MSG_NOSIGNAL 0
+#define SHUT_RDWR SD_BOTH
+#define SOL_TCP IPPROTO_TCP
#define compatible_close(fd) closesocket(fd);
#ifdef __MINGW64__
#include <winsock2.h>
#include <windows.h>
#define LWS_INVALID_FILE INVALID_HANDLE_VALUE
+
+#if defined(__MINGW32__) || defined(__MINGW64__) || _WIN32_WINNT < 0x0600
+#define POLLIN 0x01
+#define POLLOUT 0x04
+#define POLLERR 0x08
+#define POLLHUP 0x10
+#endif
#else
#include <sys/types.h>
#include <sys/socket.h>
#ifdef _WIN32
WSAEVENT *events;
#endif
- struct pollfd *fds;
+ struct libwebsocket_pollfd *fds;
struct libwebsocket **lws_lookup; /* fd to wsi */
int fds_count;
#ifdef LWS_USE_LIBEV
LWS_EXTERN int
lws_handle_POLLOUT_event(struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd);
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd);
#ifndef LWS_NO_EXTENSIONS
LWS_EXTERN int
lws_any_extension_handled(struct libwebsocket_context *context,
}
int lws_server_socket_service(struct libwebsocket_context *context,
- struct libwebsocket *wsi, struct pollfd *pollfd)
+ struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
{
struct libwebsocket *new_wsi;
int accept_fd;
+++ /dev/null
-#ifndef __WEB_SOCK_W32_H__
-#define __WEB_SOCK_W32_H__
-
-// Windows uses _DEBUG and NDEBUG
-#ifdef _DEBUG
-#undef DEBUG
-#define DEBUG 1
-#endif
-
-#pragma warning(disable : 4996)
-
-#define MSG_NOSIGNAL 0
-#define SHUT_RDWR SD_BOTH
-
-#define SOL_TCP IPPROTO_TCP
-
-#ifdef __MINGW64__
-#define DEF_POLL_STUFF
-#endif
-#ifdef __MINGW32__
-#define DEF_POLL_STUFF
-#endif
-
-#if _WIN32_WINNT < 0x0600
-#define DEF_POLL_STUFF
-#endif
-
-#ifdef DEF_POLL_STUFF
-
-#include <winsock2.h>
-
-typedef struct pollfd {
- SOCKET fd;
- short events;
- short revents;
-} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
-
-#define POLLIN 0x0001 /* any readable data available */
-#define POLLOUT 0x0004 /* file descriptor is writeable */
-#define POLLERR 0x0008 /* some poll error occurred */
-#define POLLHUP 0x0010 /* file descriptor was "hung up" */
-#define POLLNVAL 0x0020 /* requested events "invalid" */
-
-#endif
-
-/* override configure because we are not using Makefiles */
-
-#define LWS_NO_FORK
-
-/* windows can't cope with this idea, needs assets in cwd */
-
-#ifndef INSTALL_DATADIR
-#define INSTALL_DATADIR "."
-#endif
-
-#endif