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

Method sock_send

crates/stdlib/src/ssl.rs:2808–2823  ·  view source on GitHub ↗

Socket send - just sends data, caller must handle pending flush Use flush_pending_tls_output before this if ordering is important

(&self, data: &[u8], vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

2806 /// Socket send - just sends data, caller must handle pending flush
2807 /// Use flush_pending_tls_output before this if ordering is important
2808 pub(crate) fn sock_send(&self, data: &[u8], vm: &VirtualMachine) -> PyResult<PyObjectRef> {
2809 // In BIO mode, write to outgoing BIO
2810 if let Some(ref bio) = self.outgoing_bio {
2811 let bio_obj: PyObjectRef = bio.clone().into();
2812 let write_method = bio_obj.get_attr("write", vm)?;
2813 return write_method.call((vm.ctx.new_bytes(data.to_vec()),), vm);
2814 }
2815
2816 // Normal socket mode
2817 let socket_mod = vm.import("socket", 0)?;
2818 let socket_class = socket_mod.get_attr("socket", vm)?;
2819
2820 // Call socket.socket.send(self.sock, data)
2821 let send_method = socket_class.get_attr("send", vm)?;
2822 send_method.call((self.sock.clone(), vm.ctx.new_bytes(data.to_vec())), vm)
2823 }
2824
2825 /// Flush any pending TLS output data to the socket
2826 /// Optional deadline parameter allows respecting a read deadline during flush

Callers 4

send_tls_outputMethod · 0.80
send_all_bytesFunction · 0.80

Calls 6

to_vecMethod · 0.80
cloneMethod · 0.45
get_attrMethod · 0.45
callMethod · 0.45
new_bytesMethod · 0.45
importMethod · 0.45

Tested by

no test coverage detected