@@ -5,7 +5,7 @@ use crate::io;
55use crate :: os:: raw:: c_int;
66use crate :: os:: windows:: net:: { SocketAddr , from_sockaddr_un} ;
77use crate :: path:: Path ;
8- use crate :: sys:: c:: { self , bind, listen} ;
8+ use crate :: sys:: c:: { self , bind, getsockname , listen} ;
99use crate :: sys:: cvt;
1010use crate :: sys:: net:: Socket ;
1111#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -33,4 +33,28 @@ impl UnixListener {
3333 let addr = from_sockaddr_un ( storage, len) ?;
3434 Ok ( ( UnixStream ( sock) , addr) )
3535 }
36+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
37+ pub fn incoming ( & self ) -> Incoming < ' _ > {
38+ Incoming { listener : self }
39+ }
40+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
41+ pub fn take_error ( & self ) -> io:: Result < Option < io:: Error > > {
42+ self . 0 . take_error ( )
43+ }
44+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
45+ pub fn set_nonblocking ( & self , nonblocking : bool ) -> io:: Result < ( ) > {
46+ self . 0 . set_nonblocking ( nonblocking)
47+ }
48+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
49+ pub fn local_addr ( & self ) -> io:: Result < SocketAddr > {
50+ SocketAddr :: new ( |addr, len| unsafe { getsockname ( self . 0 . as_raw ( ) as _ , addr, len) } )
51+ }
52+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
53+ pub fn try_clone ( & self ) -> io:: Result < UnixListener > {
54+ self . 0 . duplicate ( ) . map ( UnixListener )
55+ }
56+ }
57+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
58+ pub struct Incoming < ' a > {
59+ listener : & ' a UnixListener ,
3660}
0 commit comments