1- #![ cfg( all ( windows, feature = "windows_unix_domain_sockets" ) ) ]
2- #![ unstable ( feature = " windows_unix_domain_sockets" , issue = "none" ) ]
1+ #![ cfg( windows) ]
2+ #![ feature( windows_unix_domain_sockets) ]
33
44use std:: io:: { Read , Write } ;
55use std:: os:: windows:: net:: { UnixListener , UnixStream } ;
6- use std:: path:: Path ;
76use std:: thread;
87
98#[ test]
109fn smoke_bind_connect ( ) {
1110 let tmp = std:: env:: temp_dir ( ) ;
1211 let sock_path = tmp. join ( "rust-test-uds.sock" ) ;
1312
14- let listener = UnixListener :: bind ( & sock_path) . expect ( "bind failed" ) ;
13+ let listener = UnixListener :: bind ( sock_path. as_path ( ) ) . expect ( "bind failed" ) ;
1514
1615 let tx = thread:: spawn ( move || {
1716 let mut stream = UnixStream :: connect ( & sock_path) . expect ( "connect failed" ) ;
@@ -23,45 +22,8 @@ fn smoke_bind_connect() {
2322 stream. read_exact ( & mut buf) . expect ( "read failed" ) ;
2423 assert_eq ! ( & buf, b"hello" ) ;
2524
26- tx. join ( ) . unwrap ;
25+ tx. join ( ) . unwrap ( ) ;
2726
2827 drop ( listener) ;
2928 let _ = std:: fs:: remove_file ( & sock_path) ;
3029}
31-
32- #[ test]
33- fn echo ( ) {
34- let tmp = std:: env:: temp_dir ( ) ;
35- let sock_path = tmp. join ( "rust-test-uds-echo.sock" ) ;
36-
37- let listener = UnixListener :: bind ( & sock_path) . unwrap ( ) ;
38-
39- let tx = thread:: spawn ( move || {
40- let ( mut stream, _) = listener. accept ( ) . unwrap ;
41- let mut buf = [ 0 ; 1024 ] ;
42- loop {
43- let n = match stream. read ( & mut buf) {
44- Ok ( 0 ) => return ,
45- Ok ( n) => n,
46- Err ( e) => panic ! ( "read error: {}" , e) ,
47- } ;
48- stream. write_all ( & buf[ ..n] ) . unwrap ;
49- }
50- } ) ;
51-
52- let mut client = UnixStream :: connect ( & sock_path) . unwrap ;
53- client. write_all ( b"echo" ) . unwrap ;
54- let mut buf = [ 0 ; 4 ] ;
55- client. read_exact ( & mut buf) . unwrap ;
56- assert_eq ! ( & buf, b"echo" ) ;
57-
58- drop ( client) ;
59- tx. join ( ) . unwrap ;
60- let _ = std:: fs:: remove_file ( & sock_path) ;
61- }
62-
63- #[ test]
64- fn path_too_long ( ) {
65- let long = "\\ \\ ?\\ " . to_string ( ) + & "a" . repeat ( 300 ) ;
66- assert ! ( UnixListener :: bind( long) . is_err( ) ) ;
67- }
0 commit comments