Changeset 5 in libcf for trunk/src/cf_socket.c


Ignore:
Timestamp:
01/30/13 13:12:40 (11 years ago)
Author:
cheese
Message:

#1 add windows project and fix build compatibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_socket.c

    r4 r5  
    77#ifdef _WIN32
    88# include <WinSock2.h>
     9# pragma comment (lib, "ws2_32.lib")
     10# define close(__sock)  closesocket(__sock)
     11# define sa_family_t    unsigned short
    912#else
    1013# include <netinet/in.h>
     
    7477    CHECK_INVALID_SOCKET (sock);
    7578
    76     result = /* continued */
    77 #ifdef _WIN32
    78         closesocket (socket);
    79 #else
    80         close (sock);
    81 #endif
     79    result = close (sock);
    8280
    8381    if (result != 0)
     
    143141    int result = 0;
    144142
    145     CHECK_INVALID_SOCKET (sock);
    146 
    147     if (timeout < 0)
    148         return CF_ERROR_SOCKET_INVALID_ARGS;
    149 
    150 #ifndef _WIN32
     143#ifdef _WIN32
     144    int time_ms = timeout * 1000;
     145#else
    151146    struct timeval  timeval;
    152147    timeval.tv_sec = timeout;
    153148    timeval.tv_usec= 0;
    154 #else
    155     int             time_ms = timeout * 1000;
    156 #endif
     149#endif
     150
     151    CHECK_INVALID_SOCKET (sock);
     152
     153    if (timeout < 0)
     154        return CF_ERROR_SOCKET_INVALID_ARGS;
    157155
    158156    result = CF_Socket_SetOption (sock,
Note: See TracChangeset for help on using the changeset viewer.