Ignore:
Timestamp:
Jan 21, 2007, 7:42:11 PM (15 years ago)
Author:
titer
Message:

More simplifications

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r1420 r1425  
    223223
    224224/***********************************************************************
    225  * TCP sockets
     225 * TCP/UDP sockets
    226226 **********************************************************************/
    227227
     
    248248}
    249249
    250 static int createSocket( int type )
     250static int createSocket( int type, int priority )
    251251{
    252252    int s;
    253 
    254     s = socket( AF_INET, type, 0 );
    255     if( s < 0 )
    256     {
    257         tr_err( "Could not create socket (%s)", strerror( errno ) );
    258         return -1;
    259     }
    260 
     253    if( ( s = tr_fdSocketCreate( type, priority ) ) < 0 )
     254    {
     255        return -1;
     256    }
    261257    return makeSocketNonBlocking( s );
    262258}
    263259
    264 int tr_netOpen( struct in_addr addr, in_port_t port, int type )
     260int tr_netOpen( struct in_addr addr, in_port_t port, int type, int priority )
    265261{
    266262    int s;
    267263    struct sockaddr_in sock;
    268264
    269     s = createSocket( type );
    270     if( s < 0 )
     265    if( ( s = createSocket( type, priority ) ) < 0 )
    271266    {
    272267        return -1;
     
    329324#endif
    330325
    331     s = createSocket( type );
    332     if( s < 0 )
     326    if( ( s = createSocket( type, 1 ) ) < 0 )
    333327    {
    334328        return -1;
     
    364358}
    365359
    366 int tr_netAccept( int s, struct in_addr * addr, in_port_t * port )
    367 {
    368     int t;
    369     unsigned len;
    370     struct sockaddr_in sock;
    371 
    372     len = sizeof( sock );
    373     t   = accept( s, (struct sockaddr *) &sock, &len );
    374 
    375     if( t < 0 )
    376     {
    377         return -1;
    378     }
    379    
    380     *addr = sock.sin_addr;
    381     *port = sock.sin_port;
    382 
    383     return makeSocketNonBlocking( t );
     360int tr_netAccept( int b, struct in_addr * addr, in_port_t * port )
     361{
     362    int s;
     363    if( ( s = tr_fdSocketAccept( b, addr, port ) ) < 0 )
     364    {
     365        return -1;
     366    }
     367    return makeSocketNonBlocking( s );
    384368}
    385369
     
    432416void tr_netClose( int s )
    433417{
    434 #ifdef BEOS_NETSERVER
    435     closesocket( s );
    436 #else
    437     close( s );
    438 #endif
     418    tr_fdSocketClose( s );
    439419}
    440420
Note: See TracChangeset for help on using the changeset viewer.