Get the App
SLTechnology News&Howtos  ›  Development  › 

How python uses VS to receive data

Shulou Source: shulou.com Published: 2022-06-03 17:38:21 09月28日 Update

This article will explain in detail how python uses VS to receive data. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. Use the recvfrom function.

S.recvfrom (1024)

2. When the program is running, it will block and wait for data to be received. 1024 represents the maximum number of bytes that can be received this time.

The program should s.close () after receiving it.

3. Because the object s takes up a certain amount of space, when it is not used, it should be closed in time.

The code is as follows:

From socket import * # Import module addr = ("192.168.0.106", 8080) # prepare the address of the receiver s = socket (AF_INET,SOCK_DGRAM) s.sendto ("Hello duck" .encode ("gb2312"), addr) # send content, convert to byte stream redate = s.recvfrom (1024) print (redate) s.close () on "how python uses VS to receive data", this ends here. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Data article content more program good practical maximum code hello function address byte object recipient article module knowledge space preparation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology NVidia Linux OPPO Reno