Network sockets
A network socket address contains an IP address and port number. In a very simple way, a socket is a way to talk to other computers. By means of a socket, a process can communicate with another process over the network.
In order to create a socket, use the socket.socket()
function that is available in the socket module. The general syntax of a socket function is as follows:
s = socket.socket (socket_family, socket_type, protocol=0)
Here is the description of the parameters:
socket_family: socket.AF_INET, PF_PACKET
AF_INET
is the address family for IPv4. PF_PACKET
operates at the device driver layer. The pcap library for Linux uses PF_PACKET
. You will see more details on PF_PACKET
in Chapter 3, Sniffing and Penetration Testing. These ...
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.