[][src]Function susyp2p_core::upgrade::read_one

pub fn read_one<TSocket>(socket: TSocket, max_size: usize) -> ReadOne<TSocket>

Reads a message from the given socket. Only one message is processed and the socket is dropped, because we assume that the socket will not send anything more.

The max_size parameter is the maximum size in bytes of the message that we accept. This is necessary in order to avoid DoS attacks where the remote sends us a message of several gigabytes.

Note: Assumes that a variable-length prefix indicates the length of the message. This is compatible with what write_one does.