@@ -200,6 +200,11 @@ impl Socket {
200200 /// non-blocking mode before calling this function), socket option can't be
201201 /// set *while connecting*. This will cause errors on Windows. Socket
202202 /// options can be safely set before and after connecting the socket.
203+ ///
204+ /// On Cygwin, a Unix domain socket connect blocks until the server accepts
205+ /// it. If the behavior is not expected, try [`Socket::set_no_peercred`]
206+ /// (Cygwin only).
207+ #[ allow( rustdoc:: broken_intra_doc_links) ] // Socket::set_no_peercred
203208 pub fn connect ( & self , address : & SockAddr ) -> io:: Result < ( ) > {
204209 sys:: connect ( self . as_raw ( ) , address)
205210 }
@@ -260,6 +265,13 @@ impl Socket {
260265 /// This function sets the same flags as in done for [`Socket::new`],
261266 /// [`Socket::accept_raw`] can be used if you don't want to set those flags.
262267 #[ doc = man_links ! ( accept( 2 ) ) ]
268+ ///
269+ /// # Notes
270+ ///
271+ /// On Cygwin, a Unix domain socket connect blocks until the server accepts
272+ /// it. If the behavior is not expected, try [`Socket::set_no_peercred`]
273+ /// (Cygwin only).
274+ #[ allow( rustdoc:: broken_intra_doc_links) ] // Socket::set_no_peercred
263275 pub fn accept ( & self ) -> io:: Result < ( Socket , SockAddr ) > {
264276 // Use `accept4` on platforms that support it.
265277 #[ cfg( any(
@@ -271,6 +283,7 @@ impl Socket {
271283 target_os = "linux" ,
272284 target_os = "netbsd" ,
273285 target_os = "openbsd" ,
286+ target_os = "cygwin" ,
274287 ) ) ]
275288 return self . _accept4 ( libc:: SOCK_CLOEXEC ) ;
276289
@@ -284,6 +297,7 @@ impl Socket {
284297 target_os = "linux" ,
285298 target_os = "netbsd" ,
286299 target_os = "openbsd" ,
300+ target_os = "cygwin" ,
287301 ) ) ) ]
288302 {
289303 let ( socket, addr) = self . accept_raw ( ) ?;
@@ -752,6 +766,7 @@ const fn set_common_type(ty: Type) -> Type {
752766 target_os = "linux" ,
753767 target_os = "netbsd" ,
754768 target_os = "openbsd" ,
769+ target_os = "cygwin" ,
755770 ) ) ]
756771 let ty = ty. _cloexec ( ) ;
757772
@@ -781,6 +796,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
781796 target_os = "openbsd" ,
782797 target_os = "espidf" ,
783798 target_os = "vita" ,
799+ target_os = "cygwin" ,
784800 ) )
785801 ) ) ]
786802 socket. _set_cloexec ( true ) ?;
@@ -956,7 +972,7 @@ impl Socket {
956972 /// For more information about this option, see [`set_passcred`].
957973 ///
958974 /// [`set_passcred`]: Socket::set_passcred
959- #[ cfg( all ( unix , target_os = "linux " ) ) ]
975+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
960976 pub fn passcred ( & self ) -> io:: Result < bool > {
961977 unsafe {
962978 getsockopt :: < c_int > ( self . as_raw ( ) , sys:: SOL_SOCKET , sys:: SO_PASSCRED )
@@ -968,7 +984,7 @@ impl Socket {
968984 ///
969985 /// If this option is enabled, enables the receiving of the `SCM_CREDENTIALS`
970986 /// control messages.
971- #[ cfg( all ( unix , target_os = "linux " ) ) ]
987+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
972988 pub fn set_passcred ( & self , passcred : bool ) -> io:: Result < ( ) > {
973989 unsafe {
974990 setsockopt (
@@ -1254,6 +1270,7 @@ impl Socket {
12541270 target_os = "nto" ,
12551271 target_os = "espidf" ,
12561272 target_os = "vita" ,
1273+ target_os = "cygwin" ,
12571274 ) ) ) ]
12581275 pub fn join_multicast_v4_n (
12591276 & self ,
@@ -1287,6 +1304,7 @@ impl Socket {
12871304 target_os = "nto" ,
12881305 target_os = "espidf" ,
12891306 target_os = "vita" ,
1307+ target_os = "cygwin" ,
12901308 ) ) ) ]
12911309 pub fn leave_multicast_v4_n (
12921310 & self ,
@@ -1577,6 +1595,7 @@ impl Socket {
15771595 target_os = "nto" ,
15781596 target_os = "espidf" ,
15791597 target_os = "vita" ,
1598+ target_os = "cygwin" ,
15801599 ) ) ) ]
15811600 pub fn set_recv_tos_v4 ( & self , recv_tos : bool ) -> io:: Result < ( ) > {
15821601 unsafe {
@@ -1608,6 +1627,7 @@ impl Socket {
16081627 target_os = "nto" ,
16091628 target_os = "espidf" ,
16101629 target_os = "vita" ,
1630+ target_os = "cygwin" ,
16111631 ) ) ) ]
16121632 pub fn recv_tos_v4 ( & self ) -> io:: Result < bool > {
16131633 unsafe {
@@ -1978,6 +1998,7 @@ impl Socket {
19781998 target_os = "hurd" ,
19791999 target_os = "espidf" ,
19802000 target_os = "vita" ,
2001+ target_os = "cygwin" ,
19812002 ) )
19822003 ) ) ]
19832004 pub fn recv_hoplimit_v6 ( & self ) -> io:: Result < bool > {
@@ -2006,6 +2027,7 @@ impl Socket {
20062027 target_os = "hurd" ,
20072028 target_os = "espidf" ,
20082029 target_os = "vita" ,
2030+ target_os = "cygwin" ,
20092031 ) )
20102032 ) ) ]
20112033 pub fn set_recv_hoplimit_v6 ( & self , recv_hoplimit : bool ) -> io:: Result < ( ) > {
@@ -2063,6 +2085,7 @@ impl Socket {
20632085 target_os = "netbsd" ,
20642086 target_os = "tvos" ,
20652087 target_os = "watchos" ,
2088+ target_os = "cygwin" ,
20662089 )
20672090 ) ) ]
20682091 pub fn keepalive_interval ( & self ) -> io:: Result < Duration > {
@@ -2092,6 +2115,7 @@ impl Socket {
20922115 target_os = "netbsd" ,
20932116 target_os = "tvos" ,
20942117 target_os = "watchos" ,
2118+ target_os = "cygwin" ,
20952119 )
20962120 ) ) ]
20972121 pub fn keepalive_retries ( & self ) -> io:: Result < u32 > {
0 commit comments