File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,12 @@ impl crate::Socket {
254254 pub fn set_cloexec ( & self ) -> io:: Result < ( ) > {
255255 fcntl_add ( self . inner , libc:: FD_CLOEXEC )
256256 }
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+ }
257263}
258264
259265fn fcntl_add ( fd : SysSocket , flag : c_int ) -> io:: Result < ( ) > {
@@ -267,6 +273,22 @@ fn fcntl_add(fd: SysSocket, flag: c_int) -> io::Result<()> {
267273 }
268274}
269275
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+
270292#[ repr( transparent) ] // Required during rewriting.
271293pub struct Socket {
272294 fd : SysSocket ,
You can’t perform that action at this time.
0 commit comments