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

Method recv

crates/stdlib/src/socket.rs:1647–1661  ·  view source on GitHub ↗
(
            &self,
            bufsize: usize,
            flags: OptionalArg<i32>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1645
1646 #[pymethod]
1647 fn recv(
1648 &self,
1649 bufsize: usize,
1650 flags: OptionalArg<i32>,
1651 vm: &VirtualMachine,
1652 ) -> Result<Vec<u8>, IoOrPyException> {
1653 let flags = flags.unwrap_or(0);
1654 let mut buffer = Vec::with_capacity(bufsize);
1655 let sock = self.sock()?;
1656 let n = self.sock_op(vm, SelectKind::Read, || {
1657 sock.recv_with_flags(buffer.spare_capacity_mut(), flags)
1658 })?;
1659 unsafe { buffer.set_len(n) };
1660 Ok(buffer)
1661 }
1662
1663 #[pymethod]
1664 fn recv_into(

Callers

nothing calls this directly

Calls 3

sockMethod · 0.80
sock_opMethod · 0.80
set_lenMethod · 0.80

Tested by

no test coverage detected