June 2015
Intermediate to advanced
320 pages
7h 18m
English
Creating a socket object in Python is very straightforward. You just need to import the socket module and call the socket() class:
from socket import*
import socket
#create a TCP socket (SOCK_STREAM)
s = socket.socket(family=AF_INET, type=SOCK_STREAM, proto=0)
print('Socket created')Traditionally, the class takes plenty of parameters. Some of them are listed in the following:
AF_INET (about 90 percent of the sockets of the Internet fall under this category) or AF_UNIX, which is sometimes used as well. In Python 3, you can create a Bluetooth socket using AF_BLUETOOTH.Read now
Unlock full access