import asyncio
@asyncio.coroutine
def wget(host):
print('wget %s... ' % host)
#asyncio.open_connection接受host参数和port参数以及一些可选的
#关键字参数.返回一个reader和一个writer,
#redaer is a StreamReader instance;
#the writer is a StreamWriter instance. 这两句话什么意思?
#writer.write就和socket.send差不多…
connect = asyncio.open_connection(host, 80)
#print(connect)
reader, writer = yield from connect
#print('reader:', reader)
#print('writer:', writer)
header = 'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % host
writer.write(header.encode('utf-8'))
#[1]:对于writer.drain()的用法,它会阻塞如果writer的buffer已经满了…
#当然在我们这个例子里面buffer是充足的,因为我们只发送了几个GET请求。
#内存总线在同一时刻只能服务写操作或者读操作中的一种,这是因为总线只能以一个方向驱动。
#之前的内存控制器将写缓冲在一个写队列中来允许读请求充分利用内存总吸纳,当写队列满时,