Exemple #1
0
	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)
Exemple #2
0
	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])
Exemple #3
0
	def writer(self, fd, i):
		buf = str(i)
		n = cio.write(fd, buf)
		print("write(%s) = %d" % (repr(buf), n))

		cio.close(fd)