Changeset 11357
- Timestamp:
- Oct 28, 2010, 11:19:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/tr-lpd.c
r11299 r11357 29 29 #include <sys/time.h> 30 30 #include <unistd.h> /* close() */ 31 #include <fcntl.h> /* fcntl(), O_NONBLOCK */32 31 #include <ctype.h> /* toupper() */ 33 32 #ifdef WIN32 … … 37 36 #include <ws2tcpip.h> 38 37 typedef uint16_t in_port_t; /* all missing */ 39 extern int fcntl (int fd, int cmd, ...);40 #define O_NONBLOCK 0400041 38 #else 42 39 #include <sys/types.h> … … 47 44 /* third party */ 48 45 #include <event.h> 46 #include <evutil.h> 49 47 50 48 /* libT */ … … 252 250 * @} */ 253 251 254 255 /**256 * @brief Configures additional capabilities for a socket */257 static int258 lpd_configureSocket( int sock, int add )259 {260 #ifdef WIN32261 unsigned long flags = 1;262 263 if (add != O_NONBLOCK)264 return -1; /* not supported */265 if (ioctlsocket(sock, FIONBIO, &flags) == SOCKET_ERROR)266 return -1;267 #else268 /* read-modify-write socket flags */269 int flags = fcntl( sock, F_GETFL );270 271 if( flags < 0 )272 return -1;273 274 if( fcntl( sock, F_SETFL, add | flags ) == -1 )275 return -1;276 #endif277 278 return add;279 }280 281 252 /** 282 253 * @brief Initializes Local Peer Discovery for this node … … 311 282 goto fail; 312 283 313 /* enable non-blocking operation */ 314 if( lpd_configureSocket( lpd_socket, O_NONBLOCK ) < 0 ) 284 if( evutil_make_socket_nonblocking( lpd_socket ) < 0 ) 315 285 goto fail; 316 286 … … 351 321 goto fail; 352 322 353 /* enable non-blocking operation */ 354 if( lpd_configureSocket( lpd_socket2, O_NONBLOCK ) < 0 ) 323 if( evutil_make_socket_nonblocking( lpd_socket2 ) < 0 ) 355 324 goto fail; 356 325
Note: See TracChangeset
for help on using the changeset viewer.