sockets.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * (C) 2004-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for furhter details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  *
00012  */
00013 
00014 #ifndef SOCKETS_H
00015 #define SOCKETS_H
00016 
00017 #ifdef _WIN32
00018 typedef SOCKET              ano_socket_t;
00019 #define ano_sockread(fd, buf, len)  recv(fd, buf, len, 0)
00020 #define ano_sockwrite(fd, buf, len)  send(fd, buf, len, 0)
00021 #define ano_sockclose(fd)       closesocket(fd)
00022 #define ano_sockgeterr()        WSAGetLastError()
00023 #define ano_sockseterr(err)     WSASetLastError(err)
00024 /* ano_sockstrerror in sockutil.c */
00025 /* ano_socksetnonb in sockutil.c */
00026 #define ano_sockerrnonb(err)        (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK)
00027 #define SOCKERR_EBADF           WSAENOTSOCK
00028 #define SOCKERR_EINTR           WSAEINTR
00029 #define SOCKERR_EINVAL          WSAEINVAL
00030 #define SOCKERR_EINPROGRESS     WSAEINPROGRESS
00031 #else
00032 typedef int             ano_socket_t;
00033 #define ano_sockread(fd, buf, len)  read(fd, buf, len)
00034 #define ano_sockwrite(fd, buf, len)     write(fd, buf, len)
00035 #define ano_sockclose(fd)       close(fd)
00036 #define ano_sockgeterr()        errno
00037 #define ano_sockseterr(err)     errno = err
00038 #define ano_sockstrerror(err)       strerror(err)
00039 #define ano_socksetnonb(fd)     fcntl(fd, F_SETFL, O_NONBLOCK)
00040 #define ano_sockerrnonb(err)        (err == EINPROGRESS)
00041 #define SOCKERR_EBADF           EBADF
00042 #define SOCKERR_EINTR           EINTR
00043 #define SOCKERR_EINVAL          EINVAL
00044 #define SOCKERR_EINPROGRESS     EINPROGRESS
00045 #endif
00046 
00047 #endif

Generated on Sun Dec 30 09:26:45 2007 for Anope by  doxygen 1.5.1-20070107