General socket methods
The general socket methods are as follows:
socket.recv(bufsize)
: This method receives a TCP message from the socket. Thebufsize
argument defines the maximum data it can receive at any one time.socket.recvfrom(bufsize)
: This method receives data from the socket. The method returns a pair of values: the first value gives the received data, and the second value gives the address of the socket sending the data.socket.recv_into(buffer)
: This method receives data less than or equal tobuffer
. Thebuffer
parameter is created by thebytearray()
method. We will discuss it in an example later.socket.recvfrom_into(buffer)
: This method obtains data from the socket and writes it into the buffer. The return value is a pair (nbytes, address), ...
Get Python: Penetration Testing for Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.