Back to home page

Redis cross reference

 
 

    


0001 /* anet.c -- Basic TCP socket stuff made a bit less boring
0002  *
0003  * Copyright (c) 2006-2012, Salvatore Sanfilippo <antirez at gmail dot com>
0004  * All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions are met:
0008  *
0009  *   * Redistributions of source code must retain the above copyright notice,
0010  *     this list of conditions and the following disclaimer.
0011  *   * Redistributions in binary form must reproduce the above copyright
0012  *     notice, this list of conditions and the following disclaimer in the
0013  *     documentation and/or other materials provided with the distribution.
0014  *   * Neither the name of Redis nor the names of its contributors may be used
0015  *     to endorse or promote products derived from this software without
0016  *     specific prior written permission.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0028  * POSSIBILITY OF SUCH DAMAGE.
0029  */
0030 
0031 #ifndef ANET_H
0032 #define ANET_H
0033 
0034 #define ANET_OK 0
0035 #define ANET_ERR -1
0036 #define ANET_ERR_LEN 256
0037 
0038 #if defined(__sun)
0039 #define AF_LOCAL AF_UNIX
0040 #endif
0041 
0042 int anetTcpConnect(char *err, char *addr, int port);
0043 int anetTcpNonBlockConnect(char *err, char *addr, int port);
0044 int anetUnixConnect(char *err, char *path);
0045 int anetUnixNonBlockConnect(char *err, char *path);
0046 int anetRead(int fd, char *buf, int count);
0047 int anetResolve(char *err, char *host, char *ipbuf);
0048 int anetTcpServer(char *err, int port, char *bindaddr);
0049 int anetUnixServer(char *err, char *path, mode_t perm);
0050 int anetTcpAccept(char *err, int serversock, char *ip, int *port);
0051 int anetUnixAccept(char *err, int serversock);
0052 int anetWrite(int fd, char *buf, int count);
0053 int anetNonBlock(char *err, int fd);
0054 int anetEnableTcpNoDelay(char *err, int fd);
0055 int anetDisableTcpNoDelay(char *err, int fd);
0056 int anetTcpKeepAlive(char *err, int fd);
0057 int anetPeerToString(int fd, char *ip, int *port);
0058 int anetKeepAlive(char *err, int fd, int interval);
0059 
0060 #endif