File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -756,6 +756,15 @@ impl TcpListener {
756
756
/// ];
757
757
/// let listener = TcpListener::bind(&addrs[..]).unwrap();
758
758
/// ```
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
+ /// ```
759
768
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
760
769
pub fn bind < A : ToSocketAddrs > ( addr : A ) -> io:: Result < TcpListener > {
761
770
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 {
90
90
/// ];
91
91
/// let socket = UdpSocket::bind(&addrs[..]).expect("couldn't bind to address");
92
92
/// ```
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
+ /// ```
93
102
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
94
103
pub fn bind < A : ToSocketAddrs > ( addr : A ) -> io:: Result < UdpSocket > {
95
104
super :: each_addr ( addr, net_imp:: UdpSocket :: bind) . map ( UdpSocket )
You can’t perform that action at this time.
0 commit comments