Changeset 1425 for trunk/libtransmission/net.c
- Timestamp:
- Jan 21, 2007, 7:42:11 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/net.c
r1420 r1425 223 223 224 224 /*********************************************************************** 225 * TCP sockets225 * TCP/UDP sockets 226 226 **********************************************************************/ 227 227 … … 248 248 } 249 249 250 static int createSocket( int type )250 static int createSocket( int type, int priority ) 251 251 { 252 252 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 } 261 257 return makeSocketNonBlocking( s ); 262 258 } 263 259 264 int tr_netOpen( struct in_addr addr, in_port_t port, int type )260 int tr_netOpen( struct in_addr addr, in_port_t port, int type, int priority ) 265 261 { 266 262 int s; 267 263 struct sockaddr_in sock; 268 264 269 s = createSocket( type ); 270 if( s < 0 ) 265 if( ( s = createSocket( type, priority ) ) < 0 ) 271 266 { 272 267 return -1; … … 329 324 #endif 330 325 331 s = createSocket( type ); 332 if( s < 0 ) 326 if( ( s = createSocket( type, 1 ) ) < 0 ) 333 327 { 334 328 return -1; … … 364 358 } 365 359 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 ); 360 int 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 ); 384 368 } 385 369 … … 432 416 void tr_netClose( int s ) 433 417 { 434 #ifdef BEOS_NETSERVER 435 closesocket( s ); 436 #else 437 close( s ); 438 #endif 418 tr_fdSocketClose( s ); 439 419 } 440 420
Note: See TracChangeset
for help on using the changeset viewer.