示例#1
0
文件: test.py 项目: tsavola/cio
	def server_handle(self, fd):
		while True:
			buf = bytearray(4)
			n = cio.recv(fd, buf)
			if n == 0:
				break
			print("recv(%d) -> %s" % (fd, repr(buf[:n])))

		cio.close(fd)
示例#2
0
文件: test.py 项目: tsavola/cio
	def test(self):
		count = 8
		pipe = os.pipe()

		cio.nonblock(pipe[0])
		cio.nonblock(pipe[1])

		for i in range(count):
			cio.routine(self.writer, os.dup(pipe[1]), i)

		self.reader(pipe[0], count)

		cio.close(pipe[0])
		cio.close(pipe[1])
示例#3
0
文件: test.py 项目: tsavola/cio
	def writer(self, fd, i):
		buf = str(i)
		n = cio.write(fd, buf)
		print("write(%s) = %d" % (repr(buf), n))

		cio.close(fd)