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

Method sock_recv

crates/stdlib/src/ssl.rs:2779–2794  ·  view source on GitHub ↗

Helper to call socket methods, bypassing any SSL wrapper

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

Source from the content-addressed store, hash-verified

2777
2778 // Helper to call socket methods, bypassing any SSL wrapper
2779 pub(crate) fn sock_recv(&self, size: usize, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
2780 // In BIO mode, read from incoming BIO (flags not supported)
2781 if let Some(ref bio) = self.incoming_bio {
2782 let bio_obj: PyObjectRef = bio.clone().into();
2783 let read_method = bio_obj.get_attr("read", vm)?;
2784 return read_method.call((vm.ctx.new_int(size),), vm);
2785 }
2786
2787 // Normal socket mode
2788 let socket_mod = vm.import("socket", 0)?;
2789 let socket_class = socket_mod.get_attr("socket", vm)?;
2790
2791 // Call socket.socket.recv(self.sock, size, flags)
2792 let recv_method = socket_class.get_attr("recv", vm)?;
2793 recv_method.call((self.sock.clone(), vm.ctx.new_int(size)), vm)
2794 }
2795
2796 /// Peek at socket data without consuming it (MSG_PEEK).
2797 /// Used during TLS shutdown to avoid consuming post-TLS cleartext data.

Callers 6

try_read_close_notifyMethod · 0.45
recv_one_tls_recordFunction · 0.45
handshake_read_dataFunction · 0.45
ssl_writeFunction · 0.45

Calls 5

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

Tested by

no test coverage detected