Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in socket
#1
Hi guys i need your helps guys im new in python and i have a problem in my code here is code:
from socket import *
ip = input("ip= ")
port = input("port= ")
name = input("enter the name")
s = socket(AF_INET, SOCK_STREAM)
s.bind((ip, int(port)))
s.listen(5)
print("server chat run on port"+port)
c, addr = s.accept()
print("connected to"+str(addr))
while True:
sms = input("you> ")
c.sendall(sms)
data = c.recv(1024)
print(data)

c.close()

program work but aftter i want send something to client i see this error
Traceback (most recent call last):
File "ss.py", line 13, in <module>
c.sendall(sms)
TypeError: a bytes-like object is required, not 'str'
pls help me thank you all <3
Reply


Messages In This Thread
problem in socket - by Mamad - Nov-06-2019, 11:12 AM
RE: problem in socket - by Mamad - Nov-06-2019, 12:30 PM
RE: problem in socket - by j.crater - Nov-10-2019, 11:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Socket server problem H84Gabor 0 1,258 Jun-21-2022, 12:14 AM
Last Post: H84Gabor
  socket loop problem monamour 9 6,715 Nov-28-2019, 12:04 PM
Last Post: buran
  socket problem technoplusnl 2 12,203 Dec-11-2016, 07:33 PM
Last Post: technoplusnl

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020