@@ -200,6 +200,11 @@ impl Socket {
200
200
/// non-blocking mode before calling this function), socket option can't be
201
201
/// set *while connecting*. This will cause errors on Windows. Socket
202
202
/// 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
203
208
pub fn connect ( & self , address : & SockAddr ) -> io:: Result < ( ) > {
204
209
sys:: connect ( self . as_raw ( ) , address)
205
210
}
@@ -260,6 +265,13 @@ impl Socket {
260
265
/// This function sets the same flags as in done for [`Socket::new`],
261
266
/// [`Socket::accept_raw`] can be used if you don't want to set those flags.
262
267
#[ 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
263
275
pub fn accept ( & self ) -> io:: Result < ( Socket , SockAddr ) > {
264
276
// Use `accept4` on platforms that support it.
265
277
#[ cfg( any(
@@ -271,6 +283,7 @@ impl Socket {
271
283
target_os = "linux" ,
272
284
target_os = "netbsd" ,
273
285
target_os = "openbsd" ,
286
+ target_os = "cygwin" ,
274
287
) ) ]
275
288
return self . _accept4 ( libc:: SOCK_CLOEXEC ) ;
276
289
@@ -284,6 +297,7 @@ impl Socket {
284
297
target_os = "linux" ,
285
298
target_os = "netbsd" ,
286
299
target_os = "openbsd" ,
300
+ target_os = "cygwin" ,
287
301
) ) ) ]
288
302
{
289
303
let ( socket, addr) = self . accept_raw ( ) ?;
@@ -752,6 +766,7 @@ const fn set_common_type(ty: Type) -> Type {
752
766
target_os = "linux" ,
753
767
target_os = "netbsd" ,
754
768
target_os = "openbsd" ,
769
+ target_os = "cygwin" ,
755
770
) ) ]
756
771
let ty = ty. _cloexec ( ) ;
757
772
@@ -781,6 +796,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
781
796
target_os = "openbsd" ,
782
797
target_os = "espidf" ,
783
798
target_os = "vita" ,
799
+ target_os = "cygwin" ,
784
800
) )
785
801
) ) ]
786
802
socket. _set_cloexec ( true ) ?;
@@ -956,7 +972,7 @@ impl Socket {
956
972
/// For more information about this option, see [`set_passcred`].
957
973
///
958
974
/// [`set_passcred`]: Socket::set_passcred
959
- #[ cfg( all ( unix , target_os = "linux " ) ) ]
975
+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
960
976
pub fn passcred ( & self ) -> io:: Result < bool > {
961
977
unsafe {
962
978
getsockopt :: < c_int > ( self . as_raw ( ) , sys:: SOL_SOCKET , sys:: SO_PASSCRED )
@@ -968,7 +984,7 @@ impl Socket {
968
984
///
969
985
/// If this option is enabled, enables the receiving of the `SCM_CREDENTIALS`
970
986
/// control messages.
971
- #[ cfg( all ( unix , target_os = "linux " ) ) ]
987
+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
972
988
pub fn set_passcred ( & self , passcred : bool ) -> io:: Result < ( ) > {
973
989
unsafe {
974
990
setsockopt (
@@ -1254,6 +1270,7 @@ impl Socket {
1254
1270
target_os = "nto" ,
1255
1271
target_os = "espidf" ,
1256
1272
target_os = "vita" ,
1273
+ target_os = "cygwin" ,
1257
1274
) ) ) ]
1258
1275
pub fn join_multicast_v4_n (
1259
1276
& self ,
@@ -1287,6 +1304,7 @@ impl Socket {
1287
1304
target_os = "nto" ,
1288
1305
target_os = "espidf" ,
1289
1306
target_os = "vita" ,
1307
+ target_os = "cygwin" ,
1290
1308
) ) ) ]
1291
1309
pub fn leave_multicast_v4_n (
1292
1310
& self ,
@@ -1577,6 +1595,7 @@ impl Socket {
1577
1595
target_os = "nto" ,
1578
1596
target_os = "espidf" ,
1579
1597
target_os = "vita" ,
1598
+ target_os = "cygwin" ,
1580
1599
) ) ) ]
1581
1600
pub fn set_recv_tos_v4 ( & self , recv_tos : bool ) -> io:: Result < ( ) > {
1582
1601
unsafe {
@@ -1608,6 +1627,7 @@ impl Socket {
1608
1627
target_os = "nto" ,
1609
1628
target_os = "espidf" ,
1610
1629
target_os = "vita" ,
1630
+ target_os = "cygwin" ,
1611
1631
) ) ) ]
1612
1632
pub fn recv_tos_v4 ( & self ) -> io:: Result < bool > {
1613
1633
unsafe {
@@ -1978,6 +1998,7 @@ impl Socket {
1978
1998
target_os = "hurd" ,
1979
1999
target_os = "espidf" ,
1980
2000
target_os = "vita" ,
2001
+ target_os = "cygwin" ,
1981
2002
) )
1982
2003
) ) ]
1983
2004
pub fn recv_hoplimit_v6 ( & self ) -> io:: Result < bool > {
@@ -2006,6 +2027,7 @@ impl Socket {
2006
2027
target_os = "hurd" ,
2007
2028
target_os = "espidf" ,
2008
2029
target_os = "vita" ,
2030
+ target_os = "cygwin" ,
2009
2031
) )
2010
2032
) ) ]
2011
2033
pub fn set_recv_hoplimit_v6 ( & self , recv_hoplimit : bool ) -> io:: Result < ( ) > {
@@ -2063,6 +2085,7 @@ impl Socket {
2063
2085
target_os = "netbsd" ,
2064
2086
target_os = "tvos" ,
2065
2087
target_os = "watchos" ,
2088
+ target_os = "cygwin" ,
2066
2089
)
2067
2090
) ) ]
2068
2091
pub fn keepalive_interval ( & self ) -> io:: Result < Duration > {
@@ -2092,6 +2115,7 @@ impl Socket {
2092
2115
target_os = "netbsd" ,
2093
2116
target_os = "tvos" ,
2094
2117
target_os = "watchos" ,
2118
+ target_os = "cygwin" ,
2095
2119
)
2096
2120
) ) ]
2097
2121
pub fn keepalive_retries ( & self ) -> io:: Result < u32 > {
0 commit comments