Ignore:
Timestamp:
Sep 25, 2007, 11:10:34 PM (15 years ago)
Author:
charles
Message:
  • record the ports of incoming sockets. we might need them later if we want to disconnect and reconnect.
  • for portability, use libevent API for some socket upkeep
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r3105 r3171  
    2323 *****************************************************************************/
    2424
     25#include <assert.h>
    2526#include <errno.h>
    2627#include <stdio.h>
     
    3233#include <unistd.h>
    3334#include <fcntl.h>
     35
     36#include <evutil.h>
    3437
    3538#include "transmission.h"
     
    115118    {
    116119#ifdef BEOS_NETSERVER
    117             closesocket( s[j] );
     120        closesocket( s[j] );
    118121#else
    119             close( s[j] );
     122        EVUTIL_CLOSESOCKET( s[j] );
    120123#endif
    121124    }
     
    356359}
    357360
    358 int tr_fdSocketAccept( int b, struct in_addr * addr, tr_port_t * port )
     361int
     362tr_fdSocketAccept( int b, struct in_addr * addr, tr_port_t * port )
    359363{
    360364    int s = -1;
     
    362366    struct sockaddr_in sock;
    363367
     368    assert( addr != NULL );
     369    assert( port != NULL );
     370
    364371    tr_lockLock( gFd->lock );
    365372    if( gFd->normal < gFd->normalMax )
     
    371378    {
    372379        SocketSetPriority( s, 0 );
    373         if( NULL != addr )
    374         {
    375             *addr = sock.sin_addr;
    376         }
    377         if( NULL != port )
    378         {
    379             *port = sock.sin_port;
    380         }
     380        *addr = sock.sin_addr;
     381        *port = sock.sin_port;
    381382        gFd->normal++;
    382383    }
     
    397398        closesocket( s );
    398399#else
    399         close( s );
     400        EVUTIL_CLOSESOCKET( s );
    400401#endif
    401402        if( SocketGetPriority( s ) )
Note: See TracChangeset for help on using the changeset viewer.