Keywords: Socket, Socket programming, TCP/UDP
Continuation to🤔socket programming. There are two widely used Socket types, stream sockets, and datagram sockets. Stream sockets treat communications as a continuous stream of characters, while datagram sockets have to read entire messages at once. Each uses its own communications protocol. Stream sockets use TCP (Transmission Control Protocol), which is a reliable, stream oriented protocol, and datagram sockets use UDP (User Datagram Protocol), which is unreliable and message oriented.
TCP socket runs on top of IP (Internet Protocol). TCP is a connection-oriented communication protocol. What is this connection-oriented🤔? Connection-oriented communication is a network communication in which temporary connection must be established before any data is transferred and data stream is delivered in the same order as it was sent. I personally worked on TCP so I ‘rely’ on this protocol as it provides for the recovery of segments that get lost, are damaged, duplicated or received out of their correct order. Lets learn how to write Micropython code to download data from the internet.
Here are few real-time applications of TCP
- ESP8266 hardware
Author : Seetha Akella
Purpose : Establishing TCP Socket on Client
Language : MicroPython
Hardware : ESP8266
addr = socket.getaddrinfo("muck.wintersoasis.com",8888)[-1]
s = socket.socket()
data = s.recv(500)
print(str(data, 'utf8'), end='')
print ("data not received\n")
Here is the output of the above code.
To have more fun you can try the telnet servers to download the data.
THANK YOU and many more posts coming your way!
Please put your queries in comment section, I will get back to you with answers ASAP.
Please like and share Techawarey. Find and Like Techawarey on Facebook.😊