Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
Igor Sysoev | ff8da91 | 2004-09-29 16:00:49 +0000 | [diff] [blame] | 3 | * Copyright (C) Igor Sysoev |
Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | |
Igor Sysoev | e0af1b8 | 2002-08-16 15:27:03 +0000 | [diff] [blame] | 7 | #ifndef _NGX_SOCKET_H_INCLUDED_ |
| 8 | #define _NGX_SOCKET_H_INCLUDED_ |
| 9 | |
| 10 | |
| 11 | #include <ngx_config.h> |
| 12 | |
Igor Sysoev | 7300977 | 2003-02-06 17:21:13 +0000 | [diff] [blame] | 13 | |
Igor Sysoev | 3a40d48 | 2002-09-12 14:42:29 +0000 | [diff] [blame] | 14 | #define NGX_WRITE_SHUTDOWN SHUT_WR |
Igor Sysoev | e0af1b8 | 2002-08-16 15:27:03 +0000 | [diff] [blame] | 15 | |
| 16 | typedef int ngx_socket_t; |
| 17 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 18 | #define ngx_socket socket |
Igor Sysoev | 0ad17c0 | 2002-08-26 15:18:19 +0000 | [diff] [blame] | 19 | #define ngx_socket_n "socket()" |
| 20 | |
Igor Sysoev | 7300977 | 2003-02-06 17:21:13 +0000 | [diff] [blame] | 21 | |
Igor Sysoev | f690604 | 2004-11-25 16:17:31 +0000 | [diff] [blame] | 22 | #if (NGX_HAVE_FIONBIO) |
Igor Sysoev | 7300977 | 2003-02-06 17:21:13 +0000 | [diff] [blame] | 23 | |
| 24 | int ngx_nonblocking(ngx_socket_t s); |
| 25 | int ngx_blocking(ngx_socket_t s); |
| 26 | |
| 27 | #define ngx_nonblocking_n "ioctl(FIONBIO)" |
| 28 | #define ngx_blocking_n "ioctl(!FIONBIO)" |
| 29 | |
| 30 | #else |
| 31 | |
Igor Sysoev | ac72bd1 | 2006-05-04 15:32:46 +0000 | [diff] [blame] | 32 | #define ngx_nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) |
Igor Sysoev | 0ad17c0 | 2002-08-26 15:18:19 +0000 | [diff] [blame] | 33 | #define ngx_nonblocking_n "fcntl(O_NONBLOCK)" |
Igor Sysoev | e0af1b8 | 2002-08-16 15:27:03 +0000 | [diff] [blame] | 34 | |
Igor Sysoev | ac72bd1 | 2006-05-04 15:32:46 +0000 | [diff] [blame] | 35 | #define ngx_blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK) |
| 36 | #define ngx_blocking_n "fcntl(!O_NONBLOCK)" |
| 37 | |
Igor Sysoev | 7300977 | 2003-02-06 17:21:13 +0000 | [diff] [blame] | 38 | #endif |
| 39 | |
Igor Sysoev | 9cf7830 | 2003-06-04 17:28:33 +0000 | [diff] [blame] | 40 | int ngx_tcp_nopush(ngx_socket_t s); |
Igor Sysoev | 9cf7830 | 2003-06-04 17:28:33 +0000 | [diff] [blame] | 41 | int ngx_tcp_push(ngx_socket_t s); |
Igor Sysoev | a8fa0a6 | 2003-11-25 20:44:56 +0000 | [diff] [blame] | 42 | |
Igor Sysoev | c0edbcc | 2004-10-21 15:34:38 +0000 | [diff] [blame] | 43 | #if (NGX_LINUX) |
Igor Sysoev | a8fa0a6 | 2003-11-25 20:44:56 +0000 | [diff] [blame] | 44 | |
| 45 | #define ngx_tcp_nopush_n "setsockopt(TCP_CORK)" |
| 46 | #define ngx_tcp_push_n "setsockopt(!TCP_CORK)" |
| 47 | |
| 48 | #else |
| 49 | |
| 50 | #define ngx_tcp_nopush_n "setsockopt(TCP_NOPUSH)" |
Igor Sysoev | 9cf7830 | 2003-06-04 17:28:33 +0000 | [diff] [blame] | 51 | #define ngx_tcp_push_n "setsockopt(!TCP_NOPUSH)" |
| 52 | |
Igor Sysoev | a8fa0a6 | 2003-11-25 20:44:56 +0000 | [diff] [blame] | 53 | #endif |
Igor Sysoev | 9cf7830 | 2003-06-04 17:28:33 +0000 | [diff] [blame] | 54 | |
Igor Sysoev | 7300977 | 2003-02-06 17:21:13 +0000 | [diff] [blame] | 55 | |
Igor Sysoev | 3a40d48 | 2002-09-12 14:42:29 +0000 | [diff] [blame] | 56 | #define ngx_shutdown_socket shutdown |
| 57 | #define ngx_shutdown_socket_n "shutdown()" |
| 58 | |
Igor Sysoev | 2b54238 | 2002-08-20 14:48:28 +0000 | [diff] [blame] | 59 | #define ngx_close_socket close |
Igor Sysoev | 7e932d6 | 2004-11-12 14:35:09 +0000 | [diff] [blame] | 60 | #define ngx_close_socket_n "close() socket" |
Igor Sysoev | 2b54238 | 2002-08-20 14:48:28 +0000 | [diff] [blame] | 61 | |
Igor Sysoev | e0af1b8 | 2002-08-16 15:27:03 +0000 | [diff] [blame] | 62 | |
| 63 | #endif /* _NGX_SOCKET_H_INCLUDED_ */ |