Ignore:
Timestamp:
Jul 31, 2007, 4:55:47 PM (14 years ago)
Author:
charles
Message:

get the socket/net code working on win32 too

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.h

    r2573 r2576  
    2626#define _TR_NET_H_
    2727
    28 #if defined(BEOS_NETSERVER) || defined(__MINGW__)
    29 #include <stdint.h>
    30 typedef uint16_t tr_port_t;
     28#ifdef WIN32
     29    #include <stdint.h>
     30    #include <winsock2.h>
     31    typedef uint16_t tr_port_t;
    3132#else
    32 #include <arpa/inet.h>
    33 typedef in_port_t tr_port_t;
     33    #include <sys/socket.h>
     34    #include <netinet/in.h>
     35    #include <arpa/inet.h>
     36    typedef in_port_t tr_port_t;
     37#endif
     38
     39#ifdef SYS_BEOS
     40    #include <stdint.h>
     41    typedef uint32_t socklen_t;
     42#endif
     43
     44#ifdef WIN32
     45    #define EAGAIN       WSAEAGAIN
     46    #define ECONNREFUSED WSAECONNREFUSED
     47    #define ECONNRESET   WSAECONNRESET
     48    #define EHOSTUNREACH WSAEHOSTUNREACH
     49    #define EINPROGRESS  WSAEINPROGRESS
     50    #define ENOTCONN     WSAENOTCONN
     51    #define EWOULDBLOCK  WSAEWOULDBLOCK
     52    #define sockerrno WSAGetLastError( )
     53#else
     54    #include <errno.h>
     55    #define sockerrno errno
     56#endif
     57
     58#ifndef INADDR_NONE
     59#define INADDR_NONE 0xffffffff
    3460#endif
    3561
     
    4369
    4470typedef struct tr_resolve_s tr_resolve_t;
    45 void           tr_netResolveThreadInit();
    46 void           tr_netResolveThreadClose();
     71void           tr_netResolveThreadInit( void );
     72void           tr_netResolveThreadClose( void );
    4773tr_resolve_t * tr_netResolveInit( const char * address );
    4874tr_tristate_t  tr_netResolvePulse( tr_resolve_t *, struct in_addr * );
     
    5379 * TCP and UDP sockets
    5480 **********************************************************************/
    55 int  tr_netOpenTCP ( const struct in_addr * addr, tr_port_t port, int priority );
    56 int  tr_netOpenUDP ( const struct in_addr * addr, tr_port_t port, int priority );
     81int  tr_netOpenTCP  ( const struct in_addr * addr, tr_port_t port, int priority );
     82int  tr_netOpenUDP  ( const struct in_addr * addr, tr_port_t port, int priority );
    5783int  tr_netMcastOpen( int port, const struct in_addr * addr );
    58 int  tr_netBindTCP ( int port );
    59 int  tr_netBindUDP ( int port );
    60 int  tr_netAccept  ( int s, struct in_addr *, tr_port_t * );
    61 void tr_netClose   ( int s );
     84int  tr_netBindTCP  ( int port );
     85int  tr_netBindUDP  ( int port );
     86int  tr_netAccept   ( int s, struct in_addr *, tr_port_t * );
     87void tr_netClose    ( int s );
    6288
    6389#define TR_NET_BLOCK 0x80000000
Note: See TracChangeset for help on using the changeset viewer.