src/os/win32/ngx_socket.h - nginx-1.31.9 nginx/ @ 2a3a19c6f

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_SOCKET_H_INCLUDED_
  6. ‌#define _NGX_SOCKET_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>


  9. ‌#define NGX_WRITE_SHUTDOWN SD_SEND
  10. ‌#define NGX_READ_SHUTDOWN  SD_RECEIVE
  11. ‌#define NGX_RDWR_SHUTDOWN  SD_BOTH


  12. ‌typedef SOCKET  ngx_socket_t;
  13. ‌typedef int     socklen_t;


  14. ‌#define ngx_socket(af, type, proto)                                          \
  15.     WSASocketW(af, type, proto, NULL, 0, WSA_FLAG_OVERLAPPED)

  16. ‌#define ngx_socket_n        "WSASocketW()"

  17. int ngx_nonblocking(ngx_socket_t s);
  18. int ngx_blocking(ngx_socket_t s);

  19. ‌#define ngx_nonblocking_n   "ioctlsocket(FIONBIO)"
  20. ‌#define ngx_blocking_n      "ioctlsocket(!FIONBIO)"

  21. int ngx_socket_nread(ngx_socket_t s, int *n);
  22. ‌#define ngx_socket_nread_n  "ioctlsocket(FIONREAD)"

  23. ‌#define ngx_shutdown_socket    shutdown
  24. ‌#define ngx_shutdown_socket_n  "shutdown()"

  25. ‌#define ngx_close_socket    closesocket
  26. ‌#define ngx_close_socket_n  "closesocket()"


  27. #if (NGX_HAVE_POLL && !defined POLLIN)

  28. /*
  29. * WSAPoll() is only available if _WIN32_WINNT >= 0x0600.
  30. * If it is not available during compilation, we try to
  31. * load it dynamically at runtime.
  32. */

  33. ‌#define NGX_LOAD_WSAPOLL 1

  34. ‌#define POLLRDNORM  0x0100
  35. ‌#define POLLRDBAND  0x0200
  36. ‌#define POLLIN      (POLLRDNORM | POLLRDBAND)
  37. ‌#define POLLPRI     0x0400

  38. ‌#define POLLWRNORM  0x0010
  39. ‌#define POLLOUT     (POLLWRNORM)
  40. ‌#define POLLWRBAND  0x0020

  41. ‌#define POLLERR     0x0001
  42. ‌#define POLLHUP     0x0002
  43. ‌#define POLLNVAL    0x0004

  44. ‌typedef struct pollfd {

  45.     SOCKET  fd;
  46.     SHORT   events;
  47.     SHORT   revents;

  48. ‌‌‌} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;

  49. ‌typedef int (WSAAPI *ngx_wsapoll_pt)(
  50.     LPWSAPOLLFD fdArray,
  51.     ULONG fds,
  52.     INT timeout
  53.     );

  54. extern ngx_wsapoll_pt             WSAPoll;
  55. extern ngx_uint_t                 ngx_have_wsapoll;

  56. #endif


  57. int ngx_tcp_push(ngx_socket_t s);
  58. ‌#define ngx_tcp_push_n            "tcp_push()"


  59. #endif /* _NGX_SOCKET_H_INCLUDED_ */