diff options
Diffstat (limited to 'examples/redis-unstable/src/anet.h')
| -rw-r--r-- | examples/redis-unstable/src/anet.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/examples/redis-unstable/src/anet.h b/examples/redis-unstable/src/anet.h new file mode 100644 index 0000000..1d3aec9 --- /dev/null +++ b/examples/redis-unstable/src/anet.h @@ -0,0 +1,58 @@ +/* anet.c -- Basic TCP socket stuff made a bit less boring + * + * Copyright (c) 2006-Present, Redis Ltd. + * All rights reserved. + * + * Licensed under your choice of (a) the Redis Source Available License 2.0 + * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the + * GNU Affero General Public License v3 (AGPLv3). + */ + +#ifndef ANET_H +#define ANET_H + +#include <sys/types.h> + +#define ANET_OK 0 +#define ANET_ERR -1 +#define ANET_ERR_LEN 256 + +/* Flags used with certain functions. */ +#define ANET_NONE 0 +#define ANET_IP_ONLY (1<<0) +#define ANET_PREFER_IPV4 (1<<1) +#define ANET_PREFER_IPV6 (1<<2) + +#if defined(__sun) || defined(_AIX) +#define AF_LOCAL AF_UNIX +#endif + +#ifdef _AIX +#undef ip_len +#endif + +int anetTcpNonBlockConnect(char *err, const char *addr, int port); +int anetTcpNonBlockBestEffortBindConnect(char *err, const char *addr, int port, const char *source_addr); +int anetResolve(char *err, char *host, char *ipbuf, size_t ipbuf_len, int flags); +int anetTcpServer(char *err, int port, char *bindaddr, int backlog); +int anetTcp6Server(char *err, int port, char *bindaddr, int backlog); +int anetUnixServer(char *err, char *path, mode_t perm, int backlog); +int anetTcpAccept(char *err, int serversock, char *ip, size_t ip_len, int *port); +int anetUnixAccept(char *err, int serversock); +int anetNonBlock(char *err, int fd); +int anetBlock(char *err, int fd); +int anetCloexec(int fd); +int anetEnableTcpNoDelay(char *err, int fd); +int anetDisableTcpNoDelay(char *err, int fd); +int anetSendTimeout(char *err, int fd, long long ms); +int anetRecvTimeout(char *err, int fd, long long ms); +int anetFdToString(int fd, char *ip, size_t ip_len, int *port, int remote); +int anetKeepAlive(char *err, int fd, int interval); +int anetFormatAddr(char *fmt, size_t fmt_len, char *ip, int port); +int anetPipe(int fds[2], int read_flags, int write_flags); +int anetSetSockMarkId(char *err, int fd, uint32_t id); +int anetGetError(int fd); +int anetIsFifo(char *filepath); +int anetAcceptFailureNeedsRetry(int err); + +#endif |
