sir i am developing server client program in python. when i try to run the client it gives me an error, saying
clientSocket.sendto(message, addr) TypeError: a bytes-like object is required, not 'str'
what is the possible reson for this.? how to pass it as a bytes strings? any help would be highly aprriciated
import time
from socket import *
for pings in range(10):
clientSocket = socket(AF_INET, SOCK_DGRAM)
clientSocket.settimeout(1)
message = 'test'
addr = ("127.0.0.1", 12000)
start = time.time()
clientSocket.sendto(message, addr)
try:
data, server = clientSocket.recvfrom(1024)
end = time.time()
elapsed = end - start
print ("%s %d %d") % (data, pings, elapsed)
except timeout:
print ("REQUEST TIMED OUT")