~mordred/libmemcached/fix850399

« back to all changes in this revision

Viewing changes to libmemcached/platform.h

  • Committer: Trond Norbye
  • Date: 2010-07-27 22:38:51 UTC
  • mto: This revision was merged to the branch mainline in revision 887.
  • Revision ID: trond.norbye@gmail.com-20100727223851-4g3jtln2ubxh7phs
Initial support for Windows

In order to support Windows without adding a lot of #ifdefs all over
the code I decided to move all the inclusions of platform-specific
network headers into a separate include file. Windows use separate
subsystem for sockets (WinSock), and it is almost compatible with how
it works on Unix except from:

* The socket handle is a SOCKET and not a typical filedescriptor.
* It should be closed with closesocket() and not close().
* It does not set the global errno variable, but one should call
  WSAGetLastError() instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LibMemcached
 
2
 * Copyright (C) 2006-2010 Brian Aker, Trond Norbye
 
3
 * All rights reserved.
 
4
 *
 
5
 * Use and distribution licensed under the BSD license.  See
 
6
 * the COPYING file in the parent directory for full text.
 
7
 *
 
8
 * Summary: Try to hide platform-specific stuff
 
9
 *
 
10
 */
 
11
#ifndef LIBMEMCACHED_PLATFORM_H
 
12
#define LIBMEMCACHED_PLATFORM_H 1
 
13
 
 
14
#ifdef WIN32
 
15
 
 
16
#include <winsock2.h>
 
17
#include <ws2tcpip.h>
 
18
typedef short in_port_t;
 
19
#else
 
20
typedef int SOCKET;
 
21
#include <sys/socket.h>
 
22
#include <arpa/inet.h>
 
23
#include <netdb.h>
 
24
#include <sys/un.h>
 
25
#include <netinet/tcp.h>
 
26
#include <netinet/in.h>
 
27
 
 
28
#endif /* WIN32 */
 
29
 
 
30
 
 
31
#endif /* LIBMEMCACHED_PLATFORM_H */