0
What is third parameter we pass in python socket?
soc = socket.socket( SOCKET_FAMILY, SOCKET_TYPE, PROTOCOL) what is this 3rd parameter and why it's set to 0 and what are other possible values it may take? how we can use them in an program. Please provide an example if possible.
1 ответ
+ 1
YUGABDH PASHTE
If you are talking about PROTOCOL, then it is usually omitted (or set to 0) because usually interpreter 'knows' what to use according to socket_family parameter.
But if you are interested in available protocol numbers, here you are:
>>> import socket
>>> protos = {num:name[8:] for name,num in vars(socket).items() if name.startswith("IPPROTO")}
>>> for i in protos:
print(protos[i])
IP
ICMP
TCP
UDP
RAW