File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -756,6 +756,15 @@ impl TcpListener {
756756 /// ];
757757 /// let listener = TcpListener::bind(&addrs[..]).unwrap();
758758 /// ```
759+ ///
760+ /// Creates a TCP listener bound to a port assigned by the operating system
761+ /// at `127.0.0.1`.
762+ ///
763+ /// ```no_run
764+ /// use std::net::TcpListener;
765+ ///
766+ /// let socket = TcpListener::bind("127.0.0.1:0").unwrap();
767+ /// ```
759768 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
760769 pub fn bind < A : ToSocketAddrs > ( addr : A ) -> io:: Result < TcpListener > {
761770 super :: each_addr ( addr, net_imp:: TcpListener :: bind) . map ( TcpListener )
Original file line number Diff line number Diff line change @@ -90,6 +90,15 @@ impl UdpSocket {
9090 /// ];
9191 /// let socket = UdpSocket::bind(&addrs[..]).expect("couldn't bind to address");
9292 /// ```
93+ ///
94+ /// Creates a UDP socket bound to a port assigned by the operating system
95+ /// at `127.0.0.1`.
96+ ///
97+ /// ```no_run
98+ /// use std::net::UdpSocket;
99+ ///
100+ /// let socket = UdpSocket::bind("127.0.0.1:0").unwrap();
101+ /// ```
93102 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
94103 pub fn bind < A : ToSocketAddrs > ( addr : A ) -> io:: Result < UdpSocket > {
95104 super :: each_addr ( addr, net_imp:: UdpSocket :: bind) . map ( UdpSocket )
You can’t perform that action at this time.
0 commit comments