# Path: telethon/_network/transports/transport.py
# class Transport(abc.ABC):
#     # Should return a newly-created instance of itself
#     @abc.abstractmethod
#     def recreate_fresh(self):
#         pass
# 
#     @abc.abstractmethod
#     def pack(self, input: bytes) -> bytes:
#         pass
# 
#     # Should raise EOFError if it does not have enough bytes
#     @abc.abstractmethod
#     def unpack(self, input: bytes) -> (int, bytes):
#         pass


import asyncio
import socket
from .transports.transport import Transport



CHUNK_SIZE = 32 * 1024


# TODO ideally the mtproto impl would also be sans-io, but that's less pressing
class Connection:
    def __init__(self, ip, port, *, transport: Transport, loggers, local_addr=None):
        self._ip = ip
        self._port = port
        self._log = loggers[__name__]
        self._local_addr = local_addr

        self._sock = None
        self._in_buffer = bytearray()
        self._transport = transport


# Path: telethon/_network/transports/transport.py
# class Transport(abc.ABC):
#     # Should return a newly-created instance of itself
#     @abc.abstractmethod
#     def recreate_fresh(self):
#         pass
# 
#     @abc.abstractmethod
#     def pack(self, input: bytes) -> bytes:
#         pass
# 
#     # Should raise EOFError if it does not have enough bytes
#     @abc.abstractmethod
#     def unpack(self, input: bytes) -> (int, bytes):
#         pass


# Path: telethon/_network/connection.py
import asyncio
import socket
from .transports.transport import Transport




CHUNK_SIZE = 32 * 1024


# TODO ideally the mtproto impl would also be sans-io, but that's less pressing
class Connection:
    def __init__(self, ip, port, *, transport: Transport, loggers, local_addr=None):
        self._ip = ip
        self._port = port
        self._log = loggers[__name__]
        self._local_addr = local_addr

        self._sock = None
        self._in_buffer = bytearray()
        self._transport = transport


    async def connect(self, timeout=None, ssl=None):