You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
663: Add support for SO_TIMESTAMP r=asomers a=Wolvereness
This was implemented as part of my employment, and I have received permission to submit it upstream under my own name.
I implemented this with a bit of copy+pasting from the SCM_RIGHTS implementation, and it appeared to be functional when originally implemented on top of 13deb61 (tagged v0.8.0).
/// let mut buffer1 = vec![0u8; message1.len() + message2.len()];
340
+
/// let mut time1: CmsgSpace<TimeVal> = CmsgSpace::new();
341
+
/// let received1 = recvmsg(in_socket, &[IoVec::from_mut_slice(&mut buffer1)], Some(&mut time1), MsgFlags::empty()).unwrap();
342
+
/// let mut time1 = if let Some(ControlMessage::ScmTimestamp(&time1)) = received1.cmsgs().next() { time1 } else { panic!("Unexpected or no control message") };
343
+
///
344
+
/// // Receive the second
345
+
/// let mut buffer2 = vec![0u8; message1.len() + message2.len()];
346
+
/// let mut time2: CmsgSpace<TimeVal> = CmsgSpace::new();
347
+
/// let received2 = recvmsg(in_socket, &[IoVec::from_mut_slice(&mut buffer2)], Some(&mut time2), MsgFlags::empty()).unwrap();
348
+
/// let mut time2 = if let Some(ControlMessage::ScmTimestamp(&time2)) = received2.cmsgs().next() { time2 } else { panic!("Unexpected or no control message") };
349
+
///
350
+
/// // Swap if needed; UDP is unordered
351
+
/// match (received1.bytes, received2.bytes, message1.len(), message2.len()) {
0 commit comments