# from socket import * # server=socket(AF_INET,SOCK_STREAM) # server.bind(('127.2.2.2',6689)) # server.listen(5) # conn,addr=server.accept() # res1=conn.recv(10) # print('res1',res1) # res2=conn.recv(10) # print('res2',res2) # conn.close() # server.close() ''' res1 b'helloworld' res2 b'' ''' ''' res1 b'hello' res2 b'world' ''' # from socket import * # server=socket(AF_INET,SOCK_STREAM) # server.bind(('127.2.2.2',6689)) # server.listen(5) # conn,addr=server.accept() # res1=conn.recv(1) # print('res1',res1) # res2=conn.recv(10) # print('res2',res2) # conn.close() # server.close() ''' res1 b'h' res2 b'ello' ''' # from socket import * # import time # server=socket(AF_INET,SOCK_STREAM) # server.bind(('127.2.2.2',6689)) # server.listen(5) # conn,addr=server.accept() # res1=conn.recv(1) # print('res1',res1) # time.sleep(6) # res2=conn.recv(10) # print('res2',res2) # conn.close() # server.close() ''' res1 b'h' res2 b'elloworld' ''' # from socket import * # import time # server=socket(AF_INET,SOCK_STREAM) # server.bind(('127.2.2.2',6689)) # server.listen(5) # conn,addr=server.accept() # res1=conn.recv(5) # print('res1',res1) # time.sleep(6) # res2=conn.recv(5) # print('res2',res2) # conn.close() # server.close() ''' res1 b'hello' res2 b'world' ''' # from socket import * # import subprocess,struct # server=socket(AF_INET,SOCK_STREAM) # server.bind(('127.2.2.2',6688)) # server.listen(5) # while True: # conn,client_addr=server.accept() # print(client_addr) # while True: # try: # cmd=conn.recv(1024) # if not cmd:break # obj=subprocess.Popen(cmd.decode('utf-8'),shell=True, # stdout=subprocess.PIPE, # stderr=subprocess.PIPE # ) # stdout=obj.stdout.read() # stderr=obj.stderr.read() # total_size=len(stdout)+len(stderr) # headers=struct.pack('i',total_size) # conn.send(headers) # conn.send(stdout) # conn.send(stderr) # except ConnectionResetError:break # conn.close() # server.close()