-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanet.h
44 lines (39 loc) · 1.2 KB
/
anet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Hippo Memory Cached
* Copyright (C) 2012 heaven. All rights reserved.
*
* Hippo is a mini open-source cache daemon, mainly used in dynamic data cache.
*
* Use and distribution licensed under the BSD license. See
* the LICENSE file for full text.
*
* To learn more open-source code, visit: http://code.google.com/p/heavenmvc/
* Email: wangwei([email protected])
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <netdb.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#define ANET_OK 0
#define ANET_ERR -1
#define ANET_ERR_LEN 256
#define MAX_LISTEN_CLIENT_NUM 5
//Send message to client
int anet_tcp_connect(char *err, char *addr, int port);
int anet_read(int fd, void *buf, int count);
int anet_resolve(char *err, char *host, char *ipbuf);
int anet_tcp_server(char *err, int port, char *bindaddr);
int anet_accept(char *err, int serversock, char *ip, int *port);
int anet_write(int fd, void *buf, int count);
int anet_non_block(char *err, int fd);
int anet_tcp_no_delay(char *err, int fd);
int anet_tcp_keep_alive(char *err, int fd);