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/peer-io.c

    r3142 r3171  
    107107**/
    108108
    109 //static int total_io = 0;
    110 
    111109static tr_peerIo*
    112110tr_peerIoNew( struct tr_handle  * handle,
    113111              struct in_addr    * in_addr,
     112              uint16_t            port,
    114113              const uint8_t     * torrentHash,
    115114              int                 isIncoming,
     
    121120    c->handle = handle;
    122121    c->in_addr = *in_addr;
     122    c->port = port;
    123123    c->socket = socket;
    124124    c->rateToPeer = tr_rcInit( );
     
    137137tr_peerIoNewIncoming( struct tr_handle  * handle,
    138138                      struct in_addr    * in_addr,
     139                      uint16_t            port,
    139140                      int                 socket )
    140141{
    141     tr_peerIo * c;
    142 
    143142    assert( handle != NULL );
    144143    assert( in_addr != NULL );
    145144    assert( socket >= 0 );
    146145
    147     c = tr_peerIoNew( handle, in_addr, NULL, 1, socket );
    148     c->port = -1;
    149     return c;
     146    return tr_peerIoNew( handle, in_addr, port,
     147                         NULL, 1,
     148                         socket );
    150149}
    151150
     
    156155                      const uint8_t     * torrentHash )
    157156{
    158     tr_peerIo * c;
    159 
    160157    assert( handle != NULL );
    161158    assert( in_addr != NULL );
     
    163160    assert( torrentHash != NULL );
    164161
    165     c = tr_peerIoNew( handle, in_addr, torrentHash, 0,
    166                       tr_netOpenTCP( in_addr, port, 0 ) );
    167     c->port = port;
    168     return c;
     162    return tr_peerIoNew( handle, in_addr, port,
     163                         torrentHash, 0,
     164                         tr_netOpenTCP( in_addr, port, 0 ) );
    169165}
    170166
Note: See TracChangeset for help on using the changeset viewer.