materials
materials copied to clipboard
hi There, upon running the codes below, i have the problem in the last 2 lines : sock.sendto(message.format(i, time.asctime()), server_address) TypeError: a bytes-like object is required, not 'str'
Import Module
import socket import time
Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
Connect the socket to the port where the server is listening
server_address = ("localhost", 10000)
print('[+] Connecting to %s Port %s' % server_address)
message="Message No. {} | Sent By Client At Time {} "
for i in range(15): sock.sendto(message.format(i, time.asctime()), server_address)