]>
code.delx.au - gnu-emacs/blob - nt/inc/sys/socket.h
1 /* Copyright (C) 1995, 2001, 2002, 2003, 2004, 2005,
2 2006, 2007 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs 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, or (at your option)
11 GNU Emacs 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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
22 /* Workable version of <sys/socket.h> based on winsock.h */
27 /* defeat the multiple include protection */
35 /* avoid confusion with our version of select */
38 #define MUST_REDEF_SELECT
41 /* avoid clashing with our version of FD_SET if already defined */
49 /* avoid duplicate definition of timeval */
51 #define timeval ws_timeval
57 /* redefine select to reference our version */
58 #ifdef MUST_REDEF_SELECT
59 #define select sys_select
60 #undef MUST_REDEF_SELECT
63 /* revert to our version of FD_SET */
69 /* allow us to provide our own version of fd_set */
70 #define fd_set ws_fd_set
77 /* shadow functions where we provide our own wrapper */
78 #define socket sys_socket
80 #define connect sys_connect
81 #define htons sys_htons
82 #define ntohs sys_ntohs
83 #define inet_addr sys_inet_addr
84 #define gethostname sys_gethostname
85 #define gethostbyname sys_gethostbyname
86 #define getpeername sys_getpeername
87 #define getservbyname sys_getservbyname
88 #define shutdown sys_shutdown
89 #define setsockopt sys_setsockopt
90 #define listen sys_listen
91 #define getsockname sys_getsockname
92 #define accept sys_accept
93 #define recvfrom sys_recvfrom
94 #define sendto sys_sendto
96 int sys_socket(int af
, int type
, int protocol
);
97 int sys_bind (int s
, const struct sockaddr
*addr
, int namelen
);
98 int sys_connect (int s
, const struct sockaddr
*addr
, int namelen
);
99 u_short
sys_htons (u_short hostshort
);
100 u_short
sys_ntohs (u_short netshort
);
101 unsigned long sys_inet_addr (const char * cp
);
102 int sys_gethostname (char * name
, int namelen
);
103 struct hostent
* sys_gethostbyname (const char * name
);
104 struct servent
* sys_getservbyname (const char * name
, const char * proto
);
105 int sys_getpeername (int s
, struct sockaddr
*addr
, int * namelen
);
106 int sys_shutdown (int socket
, int how
);
107 int sys_setsockopt (int s
, int level
, int oname
, const void * oval
, int olen
);
108 int sys_listen (int s
, int backlog
);
109 int sys_getsockname (int s
, struct sockaddr
* name
, int * namelen
);
110 int sys_accept (int s
, struct sockaddr
*addr
, int *addrlen
);
111 int sys_recvfrom (int s
, char *buf
, int len
, int flags
,
112 struct sockaddr
*from
, int * fromlen
);
113 int sys_sendto (int s
, const char * buf
, int len
, int flags
,
114 const struct sockaddr
*to
, int tolen
);
116 /* In addition to wrappers for the winsock functions, we also provide
117 an fcntl function, for setting sockets to non-blocking mode. */
118 int fcntl (int s
, int cmd
, int options
);
120 #define O_NDELAY 04000
122 /* we are providing a real h_errno variable */
126 /* map winsock error codes to standard names */
127 #define EWOULDBLOCK WSAEWOULDBLOCK
128 #define EINPROGRESS WSAEINPROGRESS
129 #define EALREADY WSAEALREADY
130 #define ENOTSOCK WSAENOTSOCK
131 #define EDESTADDRREQ WSAEDESTADDRREQ
132 #define EMSGSIZE WSAEMSGSIZE
133 #define EPROTOTYPE WSAEPROTOTYPE
134 #define ENOPROTOOPT WSAENOPROTOOPT
135 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
136 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
137 #define EOPNOTSUPP WSAEOPNOTSUPP
138 #define EPFNOSUPPORT WSAEPFNOSUPPORT
139 #define EAFNOSUPPORT WSAEAFNOSUPPORT
140 #define EADDRINUSE WSAEADDRINUSE
141 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
142 #define ENETDOWN WSAENETDOWN
143 #define ENETUNREACH WSAENETUNREACH
144 #define ENETRESET WSAENETRESET
145 #define ECONNABORTED WSAECONNABORTED
146 #define ECONNRESET WSAECONNRESET
147 #define ENOBUFS WSAENOBUFS
148 #define EISCONN WSAEISCONN
149 #define ENOTCONN WSAENOTCONN
150 #define ESHUTDOWN WSAESHUTDOWN
151 #define ETOOMANYREFS WSAETOOMANYREFS
152 #define ETIMEDOUT WSAETIMEDOUT
153 #define ECONNREFUSED WSAECONNREFUSED
154 #define ELOOP WSAELOOP
155 /* #define ENAMETOOLONG WSAENAMETOOLONG */
156 #define EHOSTDOWN WSAEHOSTDOWN
157 #define EHOSTUNREACH WSAEHOSTUNREACH
158 /* #define ENOTEMPTY WSAENOTEMPTY */
159 #define EPROCLIM WSAEPROCLIM
160 #define EUSERS WSAEUSERS
161 #define EDQUOT WSAEDQUOT
162 #define ESTALE WSAESTALE
163 #define EREMOTE WSAEREMOTE
165 #endif /* _SOCKET_H_ */
167 /* end of socket.h */
169 /* arch-tag: e3b8b91c-aaa0-4bc4-be57-a85a1dd247b4
170 (do not change this comment) */