MCPcopy Index your code
hub / github.com/RustPython/RustPython / sock_peek

Method sock_peek

crates/stdlib/src/ssl.rs:2798–2804  ·  view source on GitHub ↗

Peek at socket data without consuming it (MSG_PEEK). Used during TLS shutdown to avoid consuming post-TLS cleartext data.

(&self, size: usize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2796 /// Peek at socket data without consuming it (MSG_PEEK).
2797 /// Used during TLS shutdown to avoid consuming post-TLS cleartext data.
2798 pub(crate) fn sock_peek(&self, size: usize, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
2799 let socket_mod = vm.import("socket", 0)?;
2800 let socket_class = socket_mod.get_attr("socket", vm)?;
2801 let recv_method = socket_class.get_attr("recv", vm)?;
2802 let msg_peek = socket_mod.get_attr("MSG_PEEK", vm)?;
2803 recv_method.call((self.sock.clone(), vm.ctx.new_int(size), msg_peek), vm)
2804 }
2805
2806 /// Socket send - just sends data, caller must handle pending flush
2807 /// Use flush_pending_tls_output before this if ordering is important

Callers 2

recv_one_tls_recordFunction · 0.80

Calls 5

importMethod · 0.45
get_attrMethod · 0.45
callMethod · 0.45
cloneMethod · 0.45
new_intMethod · 0.45

Tested by

no test coverage detected