March 2019
Beginner
490 pages
12h 40m
English
As you will see in a moment, we will create socket objects using the socket.socket() function and specify the socket type as socket.SOCK_STREAM. When we do this, the default protocol that it uses is the TCP.
For network programming in Python, we need to create a socket object and then use this to call other functions of the module. The following code will start a web server using the sockets library. The script waits for a connection to be made; if it is received, it will show the received bytes.
You can find the following code in the tcp_server.py file:
#!/usr/bin/env python3import sockethost = '127.0.0.1'port = 12345BUFFER_SIZE = 1024#The socket objects support the context manager type#so we can use it with a with statement, ...
Read now
Unlock full access