loudmouth/inc/lm-sock.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
       
     2 /*
       
     3  * Copyright (C) 2006 Imendio AB 
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public License as
       
     7  * published by the Free Software Foundation; either version 2 of the
       
     8  * License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this program; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 #ifndef __LM_SOCK_H__
       
    22 #define __LM_SOCK_H__
       
    23 
       
    24 G_BEGIN_DECLS
       
    25 
       
    26 #if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION)
       
    27 #error "Only <loudmouth/loudmouth.h> can be included directly, this file may di/sappear or change contents."
       
    28 #endif
       
    29 
       
    30 #include <glib.h>
       
    31 
       
    32 #ifndef G_OS_WIN32
       
    33 
       
    34 #include <unistd.h>
       
    35 #include <netdb.h>
       
    36 #include <netinet/in.h>
       
    37 #include <sys/types.h>
       
    38 #include <sys/socket.h>
       
    39 #include <sys/time.h>
       
    40 
       
    41 #define _LM_SOCK_EINPROGRESS EINPROGRESS
       
    42 #define _LM_SOCK_EWOULDBLOCK EWOULDBLOOK
       
    43 #define _LM_SOCK_EALREADY    EALREADY
       
    44 #define _LM_SOCK_EISCONN     EISCONN
       
    45 #define _LM_SOCK_EINVAL      EINVAL
       
    46 
       
    47 //added by prima
       
    48 //to be removed later when MRT fixes the bug on return of socket connect
       
    49 #define _LM_SOCK_EEXISTS EEXIST
       
    50 //end added by prima
       
    51 
       
    52 #define _LM_SOCK_VALID(S)    ((S) >= 0)
       
    53 
       
    54 #else  /* G_OS_WIN32 */
       
    55 
       
    56 /* This means that we require Windows XP or above to build on
       
    57  * Windows, the reason for this, is that getaddrinfo() and
       
    58  * freeaddrinfo() require ws2tcpip.h functions that are only available
       
    59  * on these platforms. 
       
    60  *
       
    61  * This MUST be defined before windows.h is included.
       
    62  */
       
    63 
       
    64 
       
    65 #if (_WIN32_WINNT < 0x0501)
       
    66 #undef  WINVER
       
    67 #define WINVER 0x0501
       
    68 #undef  _WIN32_WINNT
       
    69 #define _WIN32_WINNT WINVER
       
    70 #endif
       
    71 
       
    72 #include <winsock2.h>
       
    73 #include <ws2tcpip.h>
       
    74 
       
    75 #define _LM_SOCK_EINPROGRESS WSAEINPROGRESS
       
    76 #define _LM_SOCK_EWOULDBLOCK WSAEWOULDBLOCK
       
    77 #define _LM_SOCK_EALREADY    WSAEALREADY
       
    78 #define _LM_SOCK_EISCONN     WSAEISCONN
       
    79 #define _LM_SOCK_EINVAL      WSAEINVAL
       
    80 #define _LM_SOCK_VALID(S)    ((S) != INVALID_SOCKET)
       
    81 
       
    82 #endif /* G_OS_WIN32 */
       
    83 
       
    84 G_END_DECLS
       
    85 
       
    86 #endif /* __LM_SOCK__ */