mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
introduce lws_sockfd_type
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
5f2a8155f1
commit
3b19386b10
3 changed files with 39 additions and 20 deletions
|
@ -237,26 +237,45 @@ enum libwebsocket_callback_reasons {
|
|||
LWS_CALLBACK_USER = 1000, /* user code can use any including / above */
|
||||
};
|
||||
|
||||
// argument structure for all external poll related calls
|
||||
// passed in via 'in'
|
||||
struct libwebsocket_pollargs {
|
||||
int fd; // applicable file descriptor
|
||||
int events; // the new event mask
|
||||
int prev_events; // the previous event mask
|
||||
};
|
||||
|
||||
|
||||
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
|
||||
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
|
||||
typedef SOCKET lws_sockfd_type;
|
||||
struct libwebsocket_pollfd {
|
||||
SOCKET fd;
|
||||
lws_sockfd_type fd;
|
||||
SHORT events;
|
||||
SHORT revents;
|
||||
};
|
||||
WINSOCK_API_LINKAGE int WSAAPI WSAPoll(struct libwebsocket_pollfd fdArray[], ULONG fds, INT timeout);
|
||||
#else
|
||||
|
||||
#if defined(MBED_OPERATORS)
|
||||
typedef int lws_sockfd_type;
|
||||
struct pollfd {
|
||||
lws_sockfd_type *fd;
|
||||
short events;
|
||||
short revents;
|
||||
};
|
||||
#define POLLIN 0x0001
|
||||
#define POLLPRI 0x0002
|
||||
#define POLLOUT 0x0004
|
||||
#define POLLERR 0x0008
|
||||
#define POLLHUP 0x0010
|
||||
#define POLLNVAL 0x0020
|
||||
#else
|
||||
typedef int lws_fd_type;
|
||||
#endif
|
||||
|
||||
#define libwebsocket_pollfd pollfd
|
||||
#endif
|
||||
|
||||
// argument structure for all external poll related calls
|
||||
// passed in via 'in'
|
||||
struct libwebsocket_pollargs {
|
||||
lws_sockfd_type fd; // applicable file descriptor
|
||||
int events; // the new event mask
|
||||
int prev_events; // the previous event mask
|
||||
};
|
||||
|
||||
enum libwebsocket_extension_callback_reasons {
|
||||
LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
|
||||
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
|
||||
|
@ -1356,7 +1375,7 @@ libwebsocket_canonical_hostname(struct libwebsocket_context *context);
|
|||
|
||||
LWS_VISIBLE LWS_EXTERN void
|
||||
libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi, int fd, char *name, int name_len,
|
||||
struct libwebsocket *wsi, lws_sockfd_type fd, char *name, int name_len,
|
||||
char *rip, int rip_len);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
|
|
|
@ -477,7 +477,7 @@ struct libwebsocket_context {
|
|||
int fd_random;
|
||||
int listen_service_modulo;
|
||||
int listen_service_count;
|
||||
int listen_service_fd;
|
||||
lws_sockfd_type listen_service_fd;
|
||||
int listen_service_extraseen;
|
||||
|
||||
/*
|
||||
|
@ -532,7 +532,7 @@ enum {
|
|||
LWS_EXTERN void lws_feature_status_libev(struct lws_context_creation_info *info);
|
||||
LWS_EXTERN void
|
||||
lws_libev_accept(struct libwebsocket_context *context,
|
||||
struct libwebsocket *new_wsi, int accept_fd);
|
||||
struct libwebsocket *new_wsi, lws_sockfd_type accept_fd);
|
||||
LWS_EXTERN void
|
||||
lws_libev_io(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi, int flags);
|
||||
|
@ -612,7 +612,7 @@ struct _lws_http_mode_related {
|
|||
#if defined(WIN32) || defined(_WIN32)
|
||||
HANDLE fd;
|
||||
#else
|
||||
int fd;
|
||||
lws_sockfd_type fd;
|
||||
#endif
|
||||
unsigned long filepos;
|
||||
unsigned long filelen;
|
||||
|
@ -842,7 +842,7 @@ struct libwebsocket {
|
|||
|
||||
char pending_timeout; /* enum pending_timeout */
|
||||
time_t pending_timeout_limit;
|
||||
int sock;
|
||||
lws_sockfd_type sock;
|
||||
int position_in_fds_table;
|
||||
#ifdef LWS_LATENCY
|
||||
unsigned long action_start;
|
||||
|
@ -930,13 +930,13 @@ lws_b64_selftest(void);
|
|||
|
||||
#ifdef _WIN32
|
||||
LWS_EXTERN struct libwebsocket *
|
||||
wsi_from_fd(struct libwebsocket_context *context, int fd);
|
||||
wsi_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
|
||||
|
||||
LWS_EXTERN int
|
||||
insert_wsi(struct libwebsocket_context *context, struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
delete_from_fd(struct libwebsocket_context *context, int fd);
|
||||
delete_from_fd(struct libwebsocket_context *context, lws_sockfd_type fd);
|
||||
#else
|
||||
#define wsi_from_fd(A,B) A->lws_lookup[B]
|
||||
#define insert_wsi(A,B) A->lws_lookup[B->sock]=B
|
||||
|
@ -1067,7 +1067,7 @@ void lws_http2_configure_if_upgraded(struct libwebsocket *wsi);
|
|||
#endif
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_plat_set_socket_options(struct libwebsocket_context *context, int fd);
|
||||
lws_plat_set_socket_options(struct libwebsocket_context *context, lws_sockfd_type fd);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_allocate_header_table(struct libwebsocket *wsi);
|
||||
|
@ -1152,7 +1152,7 @@ lws_ssl_pending(struct libwebsocket *wsi);
|
|||
LWS_EXTERN int
|
||||
lws_server_socket_service_ssl(struct libwebsocket_context *context,
|
||||
struct libwebsocket **wsi, struct libwebsocket *new_wsi,
|
||||
int accept_fd, struct libwebsocket_pollfd *pollfd);
|
||||
lws_sockfd_type accept_fd, struct libwebsocket_pollfd *pollfd);
|
||||
LWS_EXTERN int
|
||||
lws_ssl_close(struct libwebsocket *wsi);
|
||||
LWS_EXTERN void
|
||||
|
|
|
@ -26,7 +26,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
|
|||
struct libwebsocket_context *context)
|
||||
{
|
||||
int n;
|
||||
int sockfd;
|
||||
lws_sockfd_type sockfd;
|
||||
struct sockaddr_in sin;
|
||||
socklen_t len = sizeof(sin);
|
||||
int opt = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue