Changeset 2576


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

get the socket/net code working on win32 too

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r2569 r2576  
    117117     msw="yes"
    118118     CXXFLAGS="$CXXFLAGS -mms-bitfields -mwin32 -mwindows"
    119      CPPFLAGS="$CPPFLAGS -D__MINGW__ -DWIN32_LEAN_AND_MEAN"
     119     CPPFLAGS="$CPPFLAGS -DWIN32 -DWIN32_LEAN_AND_MEAN"
    120120     LIBS="$LIBS -lshell32 -lws2_32"
    121121     transmissionlocaledir="locale"
  • trunk/libtransmission/internal.h

    r2573 r2576  
    3434#endif
    3535
    36 #ifdef SYS_BEOS
    37 #  define socklen_t uint32_t
    38 #endif
    39 
    4036#define TR_NAME "Transmission"
    41 
    42 #ifndef INADDR_NONE
    43 #define INADDR_NONE 0xffffffff
    44 #endif
    4537
    4638#ifdef __GNUC__
  • trunk/libtransmission/natpmp.c

    r2573 r2576  
    596596    else if( TR_NET_CLOSE & res )
    597597    {
    598         if( ECONNRESET == errno || ECONNREFUSED == errno )
     598        if( ECONNRESET == sockerrno || ECONNREFUSED == sockerrno )
    599599        {
    600600            tr_dbg( "nat-pmp not supported by device" );
     
    652652
    653653    res = tr_netSend( req->fd, buf, sizeof( buf ) );
    654     if( TR_NET_CLOSE & res && EHOSTUNREACH == errno )
     654    if( TR_NET_CLOSE & res && EHOSTUNREACH == sockerrno )
    655655    {
    656656        res = TR_NET_BLOCK;
  • trunk/libtransmission/net.c

    r2573 r2576  
    8181 * gethostbyname thread.
    8282 **********************************************************************/
    83 void tr_netResolveThreadInit()
     83void tr_netResolveThreadInit( void )
    8484{
    8585    resolveDie   = 0;
     
    9797 * die and clean itself up.
    9898 **********************************************************************/
    99 void tr_netResolveThreadClose()
     99void tr_netResolveThreadClose( void )
    100100{
    101101    tr_lockLock( resolveLock );
     
    290290    if( connect( s, (struct sockaddr *) &sock,
    291291                 sizeof( struct sockaddr_in ) ) < 0 &&
    292         errno != EINPROGRESS )
     292        sockerrno != EINPROGRESS )
    293293    {
    294294        tr_err( "Could not connect socket (%s)", strerror( errno ) );
     
    416416        return ret;
    417417
    418     if( errno == ENOTCONN || errno == EAGAIN || errno == EWOULDBLOCK )
     418    if( sockerrno == ENOTCONN || sockerrno == EAGAIN || sockerrno == EWOULDBLOCK )
    419419        return TR_NET_BLOCK;
    420420
     
    431431    if( ret < 0 )
    432432    {
    433         if( errno == EAGAIN || errno == EWOULDBLOCK )
     433        if( sockerrno == EAGAIN || sockerrno == EWOULDBLOCK )
    434434        {
    435435            ret = TR_NET_BLOCK;
  • 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
  • trunk/libtransmission/platform.c

    r2573 r2576  
    846846        if( 0 > res )
    847847        {
    848             if( EAGAIN != errno )
     848            if( EAGAIN != sockerrno )
    849849            {
    850850                tr_err( "failed to read from routing socket (%s)",
    851                         strerror( errno ) );
     851                        strerror( sockerrno ) );
    852852            }
    853853            free( buf );
  • trunk/libtransmission/transmission.h

    r2554 r2576  
    5353#endif
    5454
    55 #if defined(__MINGW__)
     55#if defined(WIN32)
    5656#define TR_PATH_DELIMITER '\\'
    5757#define TR_PATH_DELIMITER_STR "\\"
  • trunk/libtransmission/upnp.c

    r2573 r2576  
    401401                    (struct sockaddr*) &sin, sizeof( sin ) ) )
    402402    {
    403         if( EAGAIN != errno )
     403        if( EAGAIN != sockerrno )
    404404        {
    405405            tr_err( "Could not send SSDP discover message (%s)",
    406                     strerror( errno ) );
     406                    strerror( sockerrno ) );
    407407        }
    408408        killSock( &fd );
     
    508508    else if( TR_NET_CLOSE & *len )
    509509    {
    510         tr_err( "Could not receive SSDP message (%s)", strerror( errno ) );
     510        tr_err( "Could not receive SSDP message (%s)", strerror( sockerrno ) );
    511511        return TR_NET_ERROR;
    512512    }
Note: See TracChangeset for help on using the changeset viewer.