代码拉取完成,页面将自动刷新
同步操作将从 张鹏/qytang_Python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import sys, os, multiprocessing
from socket_stream_redirect import *
def server1():
mypid = os.getpid()
conn = initListenerSocket()
file = conn.makefile('r')
for i in range(3):
data = file.readline().rstrip()
print('server %s get [%s]' % (mypid, data))
def client1():
mypid = os.getpid()
redirectOut()
for i in range(3):
print('client %s: %s' % (mypid, i))
sys.stdout.flush()
##############################################################
def server2():
mypid = os.getpid()
conn = initListenerSocket()
for i in range(3):
conn.send(('server %s: %s\n' % (mypid, i)).encode())
def client2():
mypid = os.getpid()
redirectIn()
for i in range(3):
data = input()
print('client %s get [%s]' % (mypid, data))
##############################################################
def server3():
mypid = os.getpid()
conn = initListenerSocket()
file = conn.makefile('r')
for i in range(3):
data = file.readline().rstrip()
conn.send(('server %s got [%s]\n' % (mypid, data)).encode())
def client3():
mypid = os.getpid()
redirectBothAsClient()
for i in range(3):
print('client %s: %s' % (mypid, i))
data = input()
sys.stderr.write('client %s got [%s]\n' % (mypid, data))
##############################################################
def server4():
mypid = os.getpid()
sock = socket(AF_INET, SOCK_STREAM)
sock.connect((host, port))
file = sock.makefile('r')
for i in range(3):
sock.send(('server %s: %s\n' % (mypid, i)).encode())
data = file.readline().rstrip()
print('server %s got [%s]' % (mypid, data))
def client4():
mypid = os.getpid()
redirectBothAsServer()
for i in range(3):
data = input()
print('client %s got [%s]' % (mypid, data))
sys.stdout.flush()
##############################################################
def server5():
mypid = os.getpid()
conn = initListenerSocket()
file = conn.makefile('r')
for i in range(3):
conn.send(('server %s: %s\n' % (mypid, i)).encode())
data = file.readline().rstrip()
print('server %s got [%s]' % (mypid, data))
def client5():
mypid = os.getpid()
redirectBothAsClient()
for i in range(3):
data = input()
print('client %s got [%s]\n' % (mypid, data))
sys.stdout.flush()
if __name__ == '__main__':
server = eval('server' + sys.argv[1])
client = eval('client' + sys.argv[1])
multiprocessing.Process(target = server).start()
client()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。