def connect(cls, address, client_side=False, timeout=None, family=AF_INET, type_=SOCK_STREAM, proto=0): assert getcurrent() != hub, 'could not call block func in main loop' sock = realsocket(family, type_, proto) errno = sock.connect_ex(address) if errno in connecting_error: rw_io = io(sock.fileno(), READ | WRITE) rw_gr = getcurrent() rw_io.start(rw_gr.switch) if timeout: rw_timer = timer(timeout) rw_timer.start(rw_gr.throw, Timeout) try: rw_gr.parent.switch() finally: if timeout: rw_timer.stop() rw_io.stop() rw_timer = rw_io = None errno = sock.connect_ex(address) if errno != 0 and errno != EISCONN: raise socket_error(errno, strerror(errno)) return cls(sock, client_side)
def sendto(self, string, arg1, arg2=None): raise socket_error(errno.EPROTO)