File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -424,6 +424,12 @@ impl UnixStream {
424
424
self . 0 . passcred ( )
425
425
}
426
426
427
+ #[ cfg( any( doc, target_os = "linux" , target_os = "freebsd" , ) ) ]
428
+ #[ unstable( feature = "unix_set_mark" , issue = "none" ) ]
429
+ pub fn set_mark ( & self , mark : u32 ) -> io:: Result < ( ) > {
430
+ self . 0 . set_mark ( mark)
431
+ }
432
+
427
433
/// Returns the value of the `SO_ERROR` option.
428
434
///
429
435
/// # Examples
Original file line number Diff line number Diff line change @@ -427,6 +427,16 @@ impl Socket {
427
427
self . 0 . set_nonblocking ( nonblocking)
428
428
}
429
429
430
+ #[ cfg( target_os = "linux" ) ]
431
+ pub fn set_mark ( & self , mark : u32 ) -> io:: Result < ( ) > {
432
+ setsockopt ( self , libc:: SOL_SOCKET , libc:: SO_MARK , mark as libc:: c_int )
433
+ }
434
+
435
+ #[ cfg( target_os = "freebsd" ) ]
436
+ pub fn set_mark ( & self , mark : u32 ) -> io:: Result < ( ) > {
437
+ setsockopt ( self , libc:: SOL_SOCKET , libc:: SO_USER_COOKIE , mark)
438
+ }
439
+
430
440
pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
431
441
let raw: c_int = getsockopt ( self , libc:: SOL_SOCKET , libc:: SO_ERROR ) ?;
432
442
if raw == 0 { Ok ( None ) } else { Ok ( Some ( io:: Error :: from_raw_os_error ( raw as i32 ) ) ) }
You can’t perform that action at this time.
0 commit comments