source: sock.h @ c564e25

Last change on this file since c564e25 was 25b5a4a, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-10-03T03:03:19Z

Make sure events_*.c are fully compatible to callers so plugins built for
a different flavour will still work.

  • Property mode set to 100644
File size: 934 bytes
Line 
1#include <errno.h>
2#include <fcntl.h>
3
4#ifndef _WIN32
5#include <unistd.h>
6#include <sys/socket.h>
7#include <netinet/in.h>
8#include <arpa/inet.h>
9#include <netdb.h>
10#define sock_make_nonblocking(fd) fcntl(fd, F_SETFL, O_NONBLOCK)
11#define sock_make_blocking(fd) fcntl(fd, F_SETFL, 0)
12#define sockerr_again() (errno == EINPROGRESS || errno == EINTR)
13void closesocket( int fd );
14#else
15# include <winsock2.h>
16# include <ws2tcpip.h>
17# if !defined(BITLBEE_CORE) && defined(_MSC_VER)
18#   pragma comment(lib,"bitlbee.lib")
19# endif
20# include <io.h>
21# define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); }
22# define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); }
23# define sockerr_again() (WSAGetLastError() == WSAEINTR || WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK)
24# define ETIMEDOUT WSAETIMEDOUT
25# define sleep(a) Sleep(a*1000)
26#endif
Note: See TracBrowser for help on using the repository browser.