File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,12 @@ impl crate::Socket {
254
254
pub fn set_cloexec ( & self ) -> io:: Result < ( ) > {
255
255
fcntl_add ( self . inner , libc:: FD_CLOEXEC )
256
256
}
257
+
258
+ /// Sets `SO_NOSIGPIPE` to one.
259
+ #[ cfg( target_vendor = "apple" ) ]
260
+ pub fn set_nosigpipe ( & self ) -> io:: Result < ( ) > {
261
+ unsafe { setsockopt ( self . inner , libc:: SOL_SOCKET , libc:: SO_NOSIGPIPE , 1i32 ) }
262
+ }
257
263
}
258
264
259
265
fn fcntl_add ( fd : SysSocket , flag : c_int ) -> io:: Result < ( ) > {
@@ -267,6 +273,22 @@ fn fcntl_add(fd: SysSocket, flag: c_int) -> io::Result<()> {
267
273
}
268
274
}
269
275
276
+ #[ cfg( target_vendor = "apple" ) ]
277
+ unsafe fn setsockopt < T > ( fd : SysSocket , opt : c_int , val : c_int , payload : T ) -> io:: Result < ( ) >
278
+ where
279
+ T : Copy ,
280
+ {
281
+ let payload = & payload as * const T as * const c_void ;
282
+ syscall ! ( setsockopt(
283
+ fd,
284
+ opt,
285
+ val,
286
+ payload,
287
+ mem:: size_of:: <T >( ) as libc:: socklen_t,
288
+ ) ) ?;
289
+ Ok ( ( ) )
290
+ }
291
+
270
292
#[ repr( transparent) ] // Required during rewriting.
271
293
pub struct Socket {
272
294
fd : SysSocket ,
You can’t perform that action at this time.
0 commit comments