Nov-06-2019, 11:12 AM
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
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