When I create a server and a clint, I cannot send commands to them this code server to connect clint
:-
import socket
s = socket.socket()
h="192.168.1.2"
p=665
s.bind((h, p))
print ("YOUR SESSION HAS BEEN CREATED IN PORT : ", p)
s.listen(1)
v, addr = s.accept()
print("SUCCESS CONECTION ...", addr)
mssge = input ("==> ")
while mssge != 'e':
v.send(mssge)
data = v.recv(1024)
print (data)
mssge = input ("==> ")
s.close()
and i go to deffrant terminal and rin clint code and this code clint :-
import subprocess
import socket
s= socket.socket()
h="192.168.1.2"
p=665
s.connect((h, p))
while True:
data=s.recv(1024)
if not data:
break
co = subprocess.Popen(data, shell=True,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
ct = co.stdout.read() + co.stderr.read()
cf = str(ct)
s.send(cf)
s.close()
after connect when i right any commend I have a problem and this error :-
YOUR SESSION HAS BEEN CREATED IN PORT : 665
SUCCESS CONECTION ... ('192.168.1.2', 49508)
==> ls
Traceback (most recent call last):
File "/root/i.py", line 13, in <module>
v.send(mssge)
TypeError: a bytes-like object is required, not 'str'
please some help