@@ -202,6 +202,11 @@ impl Socket {
202
202
/// non-blocking mode before calling this function), socket option can't be
203
203
/// set *while connecting*. This will cause errors on Windows. Socket
204
204
/// options can be safely set before and after connecting the socket.
205
+ ///
206
+ /// On Cygwin, a Unix domain socket connect blocks until the server accepts
207
+ /// it. If the behavior is not expected, try [`Socket::set_no_peercred`]
208
+ /// (Cygwin only).
209
+ #[ allow( rustdoc:: broken_intra_doc_links) ] // Socket::set_no_peercred
205
210
pub fn connect ( & self , address : & SockAddr ) -> io:: Result < ( ) > {
206
211
sys:: connect ( self . as_raw ( ) , address)
207
212
}
@@ -262,6 +267,13 @@ impl Socket {
262
267
/// This function sets the same flags as in done for [`Socket::new`],
263
268
/// [`Socket::accept_raw`] can be used if you don't want to set those flags.
264
269
#[ doc = man_links ! ( accept( 2 ) ) ]
270
+ ///
271
+ /// # Notes
272
+ ///
273
+ /// On Cygwin, a Unix domain socket connect blocks until the server accepts
274
+ /// it. If the behavior is not expected, try [`Socket::set_no_peercred`]
275
+ /// (Cygwin only).
276
+ #[ allow( rustdoc:: broken_intra_doc_links) ] // Socket::set_no_peercred
265
277
pub fn accept ( & self ) -> io:: Result < ( Socket , SockAddr ) > {
266
278
// Use `accept4` on platforms that support it.
267
279
#[ cfg( any(
@@ -273,6 +285,7 @@ impl Socket {
273
285
target_os = "linux" ,
274
286
target_os = "netbsd" ,
275
287
target_os = "openbsd" ,
288
+ target_os = "cygwin" ,
276
289
) ) ]
277
290
return self . _accept4 ( libc:: SOCK_CLOEXEC ) ;
278
291
@@ -286,6 +299,7 @@ impl Socket {
286
299
target_os = "linux" ,
287
300
target_os = "netbsd" ,
288
301
target_os = "openbsd" ,
302
+ target_os = "cygwin" ,
289
303
) ) ) ]
290
304
{
291
305
let ( socket, addr) = self . accept_raw ( ) ?;
@@ -765,6 +779,7 @@ const fn set_common_type(ty: Type) -> Type {
765
779
target_os = "linux" ,
766
780
target_os = "netbsd" ,
767
781
target_os = "openbsd" ,
782
+ target_os = "cygwin" ,
768
783
) ) ]
769
784
let ty = ty. _cloexec ( ) ;
770
785
@@ -794,6 +809,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
794
809
target_os = "openbsd" ,
795
810
target_os = "espidf" ,
796
811
target_os = "vita" ,
812
+ target_os = "cygwin" ,
797
813
) )
798
814
) ) ]
799
815
socket. _set_cloexec ( true ) ?;
@@ -971,8 +987,8 @@ impl Socket {
971
987
/// For more information about this option, see [`set_passcred`].
972
988
///
973
989
/// [`set_passcred`]: Socket::set_passcred
974
- #[ cfg( all ( unix , target_os = "linux " ) ) ]
975
- #[ cfg_attr( docsrs, doc( cfg( all ( unix , target_os = "linux " ) ) ) ) ]
990
+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
991
+ #[ cfg_attr( docsrs, doc( cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ) ) ]
976
992
pub fn passcred ( & self ) -> io:: Result < bool > {
977
993
unsafe {
978
994
getsockopt :: < c_int > ( self . as_raw ( ) , sys:: SOL_SOCKET , sys:: SO_PASSCRED )
@@ -984,8 +1000,8 @@ impl Socket {
984
1000
///
985
1001
/// If this option is enabled, enables the receiving of the `SCM_CREDENTIALS`
986
1002
/// control messages.
987
- #[ cfg( all ( unix , target_os = "linux " ) ) ]
988
- #[ cfg_attr( docsrs, doc( cfg( all ( unix , target_os = "linux " ) ) ) ) ]
1003
+ #[ cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ]
1004
+ #[ cfg_attr( docsrs, doc( cfg( any ( target_os = "linux" , target_os = "cygwin " ) ) ) ) ]
989
1005
pub fn set_passcred ( & self , passcred : bool ) -> io:: Result < ( ) > {
990
1006
unsafe {
991
1007
setsockopt (
@@ -1306,6 +1322,7 @@ impl Socket {
1306
1322
target_os = "nto" ,
1307
1323
target_os = "espidf" ,
1308
1324
target_os = "vita" ,
1325
+ target_os = "cygwin" ,
1309
1326
) ) ) ]
1310
1327
pub fn join_multicast_v4_n (
1311
1328
& self ,
@@ -1339,6 +1356,7 @@ impl Socket {
1339
1356
target_os = "nto" ,
1340
1357
target_os = "espidf" ,
1341
1358
target_os = "vita" ,
1359
+ target_os = "cygwin" ,
1342
1360
) ) ) ]
1343
1361
pub fn leave_multicast_v4_n (
1344
1362
& self ,
@@ -1631,6 +1649,7 @@ impl Socket {
1631
1649
target_os = "nto" ,
1632
1650
target_os = "espidf" ,
1633
1651
target_os = "vita" ,
1652
+ target_os = "cygwin" ,
1634
1653
) ) ) ]
1635
1654
pub fn set_recv_tos ( & self , recv_tos : bool ) -> io:: Result < ( ) > {
1636
1655
unsafe {
@@ -1662,6 +1681,7 @@ impl Socket {
1662
1681
target_os = "nto" ,
1663
1682
target_os = "espidf" ,
1664
1683
target_os = "vita" ,
1684
+ target_os = "cygwin" ,
1665
1685
) ) ) ]
1666
1686
pub fn recv_tos ( & self ) -> io:: Result < bool > {
1667
1687
unsafe {
@@ -2039,6 +2059,7 @@ impl Socket {
2039
2059
target_os = "hurd" ,
2040
2060
target_os = "espidf" ,
2041
2061
target_os = "vita" ,
2062
+ target_os = "cygwin" ,
2042
2063
) )
2043
2064
) ) ]
2044
2065
pub fn recv_hoplimit_v6 ( & self ) -> io:: Result < bool > {
@@ -2067,6 +2088,7 @@ impl Socket {
2067
2088
target_os = "hurd" ,
2068
2089
target_os = "espidf" ,
2069
2090
target_os = "vita" ,
2091
+ target_os = "cygwin" ,
2070
2092
) )
2071
2093
) ) ]
2072
2094
pub fn set_recv_hoplimit_v6 ( & self , recv_hoplimit : bool ) -> io:: Result < ( ) > {
@@ -2136,6 +2158,7 @@ impl Socket {
2136
2158
target_os = "netbsd" ,
2137
2159
target_os = "tvos" ,
2138
2160
target_os = "watchos" ,
2161
+ target_os = "cygwin" ,
2139
2162
)
2140
2163
) ) ]
2141
2164
#[ cfg_attr(
@@ -2185,6 +2208,7 @@ impl Socket {
2185
2208
target_os = "netbsd" ,
2186
2209
target_os = "tvos" ,
2187
2210
target_os = "watchos" ,
2211
+ target_os = "cygwin" ,
2188
2212
)
2189
2213
) ) ]
2190
2214
#[ cfg_attr(
0 commit comments