Difference between socket.PF_PACKET and socket.AF_INET in python

I just want to know what in python socket programming, when to use socket_PF_PACKET and when to use socket.AF_INET, what is the difference between them?

+4
source share
1 answer

Use AF_INET if you want to communicate using the Internet protocols: TCP or UDP. This is by far the most common choice, and almost certainly what you want.

Use PF_PACKET if you want to send and receive messages at the most basic level below the level of the Internet protocol, for example, because you yourself implement the protocol. To use PF_PACKET your process must run as root (or with special features). This is a very advanced option. If you need to ask this question, you want AF_INET , not PF_PACKET .

+5
source

Source: https://habr.com/ru/post/1502511/


All Articles