src/os/unix/ngx_socket.h - nginx-1.7.10

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. #define NGX_WRITE_SHUTDOWN SHUT_WR

  9. typedef int  ngx_socket_t;

  10. #define ngx_socket          socket
  11. #define ngx_socket_n        "socket()"


  12. #if (NGX_HAVE_FIONBIO)

  13. int ngx_nonblocking(ngx_socket_t s);
  14. int ngx_blocking(ngx_socket_t s);

  15. #define ngx_nonblocking_n   "ioctl(FIONBIO)"
  16. #define ngx_blocking_n      "ioctl(!FIONBIO)"

  17. #else

  18. #define ngx_nonblocking(s)  fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK)
  19. #define ngx_nonblocking_n   "fcntl(O_NONBLOCK)"

  20. #define ngx_blocking(s)     fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
  21. #define ngx_blocking_n      "fcntl(!O_NONBLOCK)"

  22. #endif

  23. int ngx_tcp_nopush(ngx_socket_t s);
  24. int ngx_tcp_push(ngx_socket_t s);

  25. #if (NGX_LINUX)

  26. #define ngx_tcp_nopush_n   "setsockopt(TCP_CORK)"
  27. #define ngx_tcp_push_n     "setsockopt(!TCP_CORK)"

  28. #else

  29. #define ngx_tcp_nopush_n   "setsockopt(TCP_NOPUSH)"
  30. #define ngx_tcp_push_n     "setsockopt(!TCP_NOPUSH)"

  31. #endif


  32. #define ngx_shutdown_socket    shutdown
  33. #define ngx_shutdown_socket_n  "shutdown()"

  34. #define ngx_close_socket    close
  35. #define ngx_close_socket_n  "close() socket"


  36. #endif /* _NGX_SOCKET_H_INCLUDED_ */