1 /*
2  *  LibVNCServer/LibVNCClient common platform socket defines and includes.
3  *
4  *  Copyright (C) 2020 Christian Beier <dontmind@freeshell.org>
5  *
6  *  This is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This software is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this software; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
19  *  USA.
20  */
21 
22 #ifndef _RFB_COMMON_SOCKETS_H
23 #define _RFB_COMMON_SOCKETS_H
24 
25 #ifdef WIN32
26 /*
27   Windows sockets
28  */
29 #include <winsock2.h>
30 #include <ws2tcpip.h>
31 
32 #undef EWOULDBLOCK
33 #define EWOULDBLOCK WSAEWOULDBLOCK
34 
35 #undef ETIMEDOUT
36 #define ETIMEDOUT WSAETIMEDOUT
37 
38 #undef EINTR
39 #define EINTR WSAEINTR
40 
41 #undef EINVAL
42 #define EINVAL WSAEINVAL
43 
44 /* MinGW has those, but MSVC not */
45 #ifdef _MSC_VER
46 #define SHUT_RD   SD_RECEIVE
47 #define SHUT_WR   SD_SEND
48 #define SHUT_RDWR SD_BOTH
49 #endif
50 
51 #define read(sock,buf,len) recv(sock,buf,len,0)
52 #define write(sock,buf,len) send(sock,buf,len,0)
53 
54 #else
55 /*
56   Unix sockets
57  */
58 #include <sys/socket.h>
59 #include <sys/un.h>
60 #include <netinet/in.h>
61 #include <arpa/inet.h>
62 #include <netinet/tcp.h>
63 #include <netdb.h>
64 #endif
65 
66 #endif /* _RFB_COMMON_SOCKETS_H */
67