Anope IRC Services  Version 1.8
sockets.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2004-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  *
11  *
12  */
13 
14 #ifndef SOCKETS_H
15 #define SOCKETS_H
16 
17 #ifdef _WIN32
18 typedef SOCKET ano_socket_t;
19 #define ano_sockread(fd, buf, len) recv(fd, buf, len, 0)
20 #define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0)
21 #define ano_sockclose(fd) closesocket(fd)
22 #define ano_sockgeterr() WSAGetLastError()
23 #define ano_sockseterr(err) WSASetLastError(err)
24 /* ano_sockstrerror in sockutil.c */
25 /* ano_socksetnonb in sockutil.c */
26 #define ano_sockerrnonb(err) (err == WSAEINPROGRESS || err == WSAEWOULDBLOCK)
27 #define SOCKERR_EBADF WSAENOTSOCK
28 #define SOCKERR_EINTR WSAEINTR
29 #define SOCKERR_EINVAL WSAEINVAL
30 #define SOCKERR_EINPROGRESS WSAEINPROGRESS
31 #else
32 typedef int ano_socket_t;
33 #define ano_sockread(fd, buf, len) read(fd, buf, len)
34 #define ano_sockwrite(fd, buf, len) write(fd, buf, len)
35 #define ano_sockclose(fd) close(fd)
36 #define ano_sockgeterr() errno
37 #define ano_sockseterr(err) errno = err
38 #define ano_sockstrerror(err) strerror(err)
39 #define ano_socksetnonb(fd) fcntl(fd, F_SETFL, O_NONBLOCK)
40 #define ano_sockerrnonb(err) (err == EINPROGRESS)
41 #define SOCKERR_EBADF EBADF
42 #define SOCKERR_EINTR EINTR
43 #define SOCKERR_EINVAL EINVAL
44 #define SOCKERR_EINPROGRESS EINPROGRESS
45 #endif
46 
47 #endif
int ano_socket_t
Definition: sockets.h:32