Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How to develop a UDP echo client?

from socket import *
# Set server name and port number
server_name = "localhost"
server_port = 12000
# Create a UDP socket using IPv4
client_socket = socket(AF_INET, SOCK_DGRAM)
# Get message to send to server
message = input("Input sentence to send to server:")
# Convert it into bytes
message_bytes = bytes(message, encoding='utf-8')
client_socket.sendto(message_bytes, (server_name, server_port))
# Wait for server's response
modified_message, server_address = client_socket.recvfrom(2048)
# Display it on screen
print(modified_message.decode("utf-8"))
client_socket.close()
Comment

PREVIOUS NEXT
Code Example
Python :: dataframe of one row 
Python :: how to use def in python 
Python :: max deviation in pandas 
Python :: realtime output subprocess 
Python :: lable on graph in matplotlib 
Python :: df groupby 
Python :: matplotlib legend get handles 
Python :: list pop python 
Python :: python list deep copy 
Python :: python check if number in string 
Python :: numpy array divide each row by its sum 
Python :: pandas groupby multiple columns 
Python :: convert list of lists to pandas dataframe 
Python :: how to use drf permission class with class method actions 
Python :: python dataframe save 
Python :: R sample() funciton in python 
Python :: python loop backwards 
Python :: np.arrange 
Python :: python dictionary pop key 
Python :: get char from ascii value python 
Python :: reading the JSON from a JSON object 
Python :: django abstractuser 
Python :: axios django post data 
Python :: python get line of exception 
Python :: python for loop index 
Python :: python beautifulsoup get option tag value 
Python :: python towers of hanoi recursive 
Python :: how to remove role discord bot python 
Python :: how to use django-rest-framework-datatables 
Python :: Disctionary to Array 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =