@@ -586,8 +586,11 @@ impl UdpSocket {
586586 /// receive data from the specified address.
587587 ///
588588 /// If `addr` yields multiple addresses, `connect` will be attempted with
589- /// each of the addresses until a connection is successful. If none of
590- /// the addresses are able to be connected, the error returned from the
589+ /// each of the addresses until the underlying OS function returns no
590+ /// error. Note that usually, a successful `connect` call does not specify
591+ /// that there is a remote server listening on the port, rather, such an
592+ /// error would only be detected after the first send. If the OS returns an
593+ /// error for each of the specified addresses, the error returned from the
591594 /// last connection attempt (the last address) is returned.
592595 ///
593596 /// # Examples
@@ -602,20 +605,10 @@ impl UdpSocket {
602605 /// socket.connect("127.0.0.1:8080").expect("connect function failed");
603606 /// ```
604607 ///
605- /// Create a UDP socket bound to `127.0.0.1:3400` and connect the socket to
606- /// `127.0.0.1:8080`. If that connection fails, then the UDP socket will
607- /// connect to `127.0.0.1:8081`:
608- ///
609- /// ```no_run
610- /// use std::net::{SocketAddr, UdpSocket};
611- ///
612- /// let socket = UdpSocket::bind("127.0.0.1:3400").expect("couldn't bind to address");
613- /// let connect_addrs = [
614- /// SocketAddr::from(([127, 0, 0, 1], 8080)),
615- /// SocketAddr::from(([127, 0, 0, 1], 8081)),
616- /// ];
617- /// socket.connect(&connect_addrs[..]).expect("connect function failed");
618- /// ```
608+ /// Unlike in the TCP case, passing an array of addresses to the `connect`
609+ /// function of a UDP socket is not a useful thing to do: The OS will be
610+ /// unable to determine whether something is listening on the remote
611+ /// address without the application sending data.
619612 #[ stable( feature = "net2_mutators" , since = "1.9.0" ) ]
620613 pub fn connect < A : ToSocketAddrs > ( & self , addr : A ) -> io:: Result < ( ) > {
621614 super :: each_addr ( addr, |addr| self . 0 . connect ( addr) )
0 commit comments