blob: 9e6a859bb202d8482b70281adf8ec69f4832b085 [file] [log] [blame]
Igor Sysoevd90282d2004-09-28 08:34:51 +00001
2/*
Igor Sysoevff8da912004-09-29 16:00:49 +00003 * Copyright (C) Igor Sysoev
Igor Sysoevd90282d2004-09-28 08:34:51 +00004 */
5
6
Igor Sysoeve0af1b82002-08-16 15:27:03 +00007#ifndef _NGX_SOCKET_H_INCLUDED_
8#define _NGX_SOCKET_H_INCLUDED_
9
10
11#include <ngx_config.h>
12
Igor Sysoev73009772003-02-06 17:21:13 +000013
Igor Sysoev3a40d482002-09-12 14:42:29 +000014#define NGX_WRITE_SHUTDOWN SHUT_WR
Igor Sysoeve0af1b82002-08-16 15:27:03 +000015
16typedef int ngx_socket_t;
17
Igor Sysoev1b735832004-11-11 14:07:14 +000018#define ngx_socket socket
Igor Sysoev0ad17c02002-08-26 15:18:19 +000019#define ngx_socket_n "socket()"
20
Igor Sysoev73009772003-02-06 17:21:13 +000021
Igor Sysoevf6906042004-11-25 16:17:31 +000022#if (NGX_HAVE_FIONBIO)
Igor Sysoev73009772003-02-06 17:21:13 +000023
24int ngx_nonblocking(ngx_socket_t s);
25int 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 Sysoevac72bd12006-05-04 15:32:46 +000032#define ngx_nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK)
Igor Sysoev0ad17c02002-08-26 15:18:19 +000033#define ngx_nonblocking_n "fcntl(O_NONBLOCK)"
Igor Sysoeve0af1b82002-08-16 15:27:03 +000034
Igor Sysoevac72bd12006-05-04 15:32:46 +000035#define ngx_blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
36#define ngx_blocking_n "fcntl(!O_NONBLOCK)"
37
Igor Sysoev73009772003-02-06 17:21:13 +000038#endif
39
Igor Sysoev9cf78302003-06-04 17:28:33 +000040int ngx_tcp_nopush(ngx_socket_t s);
Igor Sysoev9cf78302003-06-04 17:28:33 +000041int ngx_tcp_push(ngx_socket_t s);
Igor Sysoeva8fa0a62003-11-25 20:44:56 +000042
Igor Sysoevc0edbcc2004-10-21 15:34:38 +000043#if (NGX_LINUX)
Igor Sysoeva8fa0a62003-11-25 20:44:56 +000044
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 Sysoev9cf78302003-06-04 17:28:33 +000051#define ngx_tcp_push_n "setsockopt(!TCP_NOPUSH)"
52
Igor Sysoeva8fa0a62003-11-25 20:44:56 +000053#endif
Igor Sysoev9cf78302003-06-04 17:28:33 +000054
Igor Sysoev73009772003-02-06 17:21:13 +000055
Igor Sysoev3a40d482002-09-12 14:42:29 +000056#define ngx_shutdown_socket shutdown
57#define ngx_shutdown_socket_n "shutdown()"
58
Igor Sysoev2b542382002-08-20 14:48:28 +000059#define ngx_close_socket close
Igor Sysoev7e932d62004-11-12 14:35:09 +000060#define ngx_close_socket_n "close() socket"
Igor Sysoev2b542382002-08-20 14:48:28 +000061
Igor Sysoeve0af1b82002-08-16 15:27:03 +000062
63#endif /* _NGX_SOCKET_H_INCLUDED_ */