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

Function recv

crates/stdlib/src/multiprocessing.rs:384–394  ·  view source on GitHub ↗
(socket: usize, size: usize, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

382
383 #[pyfunction]
384 fn recv(socket: usize, size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
385 let mut buf = vec![0u8; size];
386 let n_read =
387 unsafe { WinSock::recv(socket as SOCKET, buf.as_mut_ptr() as *mut _, size as i32, 0) };
388 if n_read < 0 {
389 Err(vm.new_last_os_error())
390 } else {
391 buf.truncate(n_read as usize);
392 Ok(buf)
393 }
394 }
395
396 #[pyfunction]
397 fn send(socket: usize, buf: ArgBytesLike, vm: &VirtualMachine) -> PyResult<libc::c_int> {

Callers 1

serve_clientMethod · 0.85

Calls 4

as_mut_ptrMethod · 0.80
new_last_os_errorMethod · 0.80
ErrClass · 0.50
truncateMethod · 0.45

Tested by

no test coverage detected