@@ -1283,6 +1283,57 @@ impl crate::Socket {
1283
1283
}
1284
1284
}
1285
1285
1286
+ /// Get the value of the `TCP_CORK` option on this socket.
1287
+ ///
1288
+ /// For more information about this option, see [`set_cork`].
1289
+ ///
1290
+ /// [`set_cork`]: Socket::set_cork
1291
+ #[ cfg( all(
1292
+ feature = "all" ,
1293
+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1294
+ ) ) ]
1295
+ #[ cfg_attr(
1296
+ docsrs,
1297
+ doc( cfg( all(
1298
+ feature = "all" ,
1299
+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1300
+ ) ) )
1301
+ ) ]
1302
+ pub fn cork ( & self ) -> io:: Result < bool > {
1303
+ unsafe {
1304
+ getsockopt :: < Bool > ( self . as_raw ( ) , libc:: IPPROTO_TCP , libc:: TCP_CORK )
1305
+ . map ( |cork| cork != 0 )
1306
+ }
1307
+ }
1308
+
1309
+ /// Set the value of the `TCP_CORK` option on this socket.
1310
+ ///
1311
+ /// If set, don't send out partial frames. All queued partial frames are
1312
+ /// sent when the option is cleared again. There is a 200 millisecond ceiling on
1313
+ /// the time for which output is corked by `TCP_CORK`. If this ceiling is reached,
1314
+ /// then queued data is automatically transmitted.
1315
+ #[ cfg( all(
1316
+ feature = "all" ,
1317
+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1318
+ ) ) ]
1319
+ #[ cfg_attr(
1320
+ docsrs,
1321
+ doc( cfg( all(
1322
+ feature = "all" ,
1323
+ any( target_os = "android" , target_os = "fuchsia" , target_os = "linux" )
1324
+ ) ) )
1325
+ ) ]
1326
+ pub fn set_cork ( & self , cork : bool ) -> io:: Result < ( ) > {
1327
+ unsafe {
1328
+ setsockopt (
1329
+ self . as_raw ( ) ,
1330
+ libc:: IPPROTO_TCP ,
1331
+ libc:: TCP_CORK ,
1332
+ cork as c_int ,
1333
+ )
1334
+ }
1335
+ }
1336
+
1286
1337
/// Gets the value for the `SO_BINDTODEVICE` option on this socket.
1287
1338
///
1288
1339
/// This value gets the socket binded device's interface name.
0 commit comments