269
269
* Supplement to <errno.h>.
271
* We redefine network-related Berkeley error symbols as the corresponding WSA
272
* constants. This allows elog.c to recognize them as being in the Winsock
273
* error code range and pass them off to pgwin32_socket_strerror(), since
274
* Windows' version of plain strerror() won't cope. Note that this will break
275
* if these names are used for anything else besides Windows Sockets errors.
276
* See TranslateSocketError() when changing this list.
279
#define EAGAIN WSAEWOULDBLOCK
273
281
#define EINTR WSAEINTR
274
#define EAGAIN WSAEWOULDBLOCK
276
283
#define EMSGSIZE WSAEMSGSIZE
277
284
#undef EAFNOSUPPORT
278
285
#define EAFNOSUPPORT WSAEAFNOSUPPORT
279
286
#undef EWOULDBLOCK
280
287
#define EWOULDBLOCK WSAEWOULDBLOCK
289
#define ECONNABORTED WSAECONNABORTED
281
290
#undef ECONNRESET
282
291
#define ECONNRESET WSAECONNRESET
283
292
#undef EINPROGRESS
284
293
#define EINPROGRESS WSAEINPROGRESS
295
#define EISCONN WSAEISCONN
286
297
#define ENOBUFS WSAENOBUFS
287
298
#undef EPROTONOSUPPORT
288
299
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
289
300
#undef ECONNREFUSED
290
301
#define ECONNREFUSED WSAECONNREFUSED
292
#define EBADFD WSAENOTSOCK
303
#define ENOTSOCK WSAENOTSOCK
293
304
#undef EOPNOTSUPP
294
305
#define EOPNOTSUPP WSAEOPNOTSUPP
297
* For Microsoft Visual Studio 2010 and above we intentionally redefine
298
* the regular Berkeley error constants and set them to the WSA constants.
299
* Note that this will break if those constants are used for anything else
300
* than Windows Sockets errors.
303
#pragma warning(disable:4005)
304
#define EMSGSIZE WSAEMSGSIZE
305
#define EAFNOSUPPORT WSAEAFNOSUPPORT
306
#define EWOULDBLOCK WSAEWOULDBLOCK
307
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
308
#define ECONNRESET WSAECONNRESET
309
#define EINPROGRESS WSAEINPROGRESS
310
#define ENOBUFS WSAENOBUFS
311
#define ECONNREFUSED WSAECONNREFUSED
312
#define EOPNOTSUPP WSAEOPNOTSUPP
313
#pragma warning(default:4005)
307
#define EADDRINUSE WSAEADDRINUSE
309
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
311
#define EHOSTUNREACH WSAEHOSTUNREACH
313
#define ENOTCONN WSAENOTCONN
317
316
* Extended locale functions with gratuitous underscore prefixes.
363
362
/* In backend/port/win32/socket.c */
365
364
#define socket(af, type, protocol) pgwin32_socket(af, type, protocol)
365
#define bind(s, addr, addrlen) pgwin32_bind(s, addr, addrlen)
366
#define listen(s, backlog) pgwin32_listen(s, backlog)
366
367
#define accept(s, addr, addrlen) pgwin32_accept(s, addr, addrlen)
367
368
#define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
368
369
#define select(n, r, w, e, timeout) pgwin32_select(n, r, w, e, timeout)
370
371
#define send(s, buf, len, flags) pgwin32_send(s, buf, len, flags)
372
373
SOCKET pgwin32_socket(int af, int type, int protocol);
374
int pgwin32_bind(SOCKET s, struct sockaddr * addr, int addrlen);
375
int pgwin32_listen(SOCKET s, int backlog);
373
376
SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
374
377
int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
375
378
int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);