materials icon indicating copy to clipboard operation
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'

Open Tan-Kwee-Khuang-alice opened this issue 3 years ago • 0 comments

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)

Tan-Kwee-Khuang-alice avatar Oct 24 '21 11:10 Tan-Kwee-Khuang-alice