mirror of https://github.com/nocturn9x/giambio.git
Added connect() method to giambio.core.AsyncSocket class
This commit is contained in:
parent
87fd7af36b
commit
5bf06031ac
|
@ -146,6 +146,10 @@ class EventLoop:
|
|||
def want_cancel(self, task):
|
||||
task.coroutine.throw(CancelledError)
|
||||
|
||||
async def connect_sock(self, sock: socket.socket, addr: tuple):
|
||||
await want_write(sock)
|
||||
return sock.connect(addr)
|
||||
|
||||
|
||||
class AsyncSocket(object):
|
||||
"""Abstraction layer for asynchronous sockets"""
|
||||
|
@ -176,6 +180,12 @@ class AsyncSocket(object):
|
|||
|
||||
await self.loop.close_sock(self.sock)
|
||||
|
||||
async def connect(self, addr: tuple):
|
||||
"""Connects the socket to an endpoint"""
|
||||
|
||||
await self.loop.connect_sock(self.sock, addr)
|
||||
|
||||
|
||||
def __enter__(self):
|
||||
return self.sock.__enter__()
|
||||
|
||||
|
|
Loading…
Reference in New Issue