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)
| 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 |
no test coverage detected