realpython / realpython/materials
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'
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 5.2k
- Forks
- 5.3k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 10
Description
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)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the UDP socket snippet shown in the issue and inspect the arguments passed to sock.sendto. Confirm that the example completes all 15 sends without the reported TypeError and that its documented behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100