# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/socket.py
# class TimeoutError(socket.timeout):
#     """A socket timeout happened."""
# 
# @contextlib.contextmanager
# def convert_eof():
#     """A context manager to convert some socket errors into EOFError."""
#     try:
#         yield
#     except ConnectionResetError:
#         raise EOFError
#     except BrokenPipeError:
#         raise EOFError
#     except OSError as exc:
#         if exc.errno in EOF:
#             raise EOFError
#         raise


import errno
import itertools
import json
import os
import os.path
import sys
import time
import traceback
            import thread
            import _thread as thread
from socket import create_connection
from .socket import TimeoutError, convert_eof
    from encodings import ascii

def _str_or_call(m):
    # TODO: Use callable() here.
    try:
        call = m.__call__
    except AttributeError:
        return str(m)
    else:
        return str(call())


class InvalidHeaderError(Exception):
    # TODO: docstring
    pass


class InvalidContentError(Exception):
    # TODO: docstring
    pass


class SocketIO(object):
    # TODO: docstring

    def __init__(self, *args, **kwargs):
        port = kwargs.pop('port', None)
        socket = kwargs.pop('socket', None)
        own_socket = kwargs.pop('own_socket', True)
        logfile = kwargs.pop('logfile', None)
        if socket is None:
            if port is None:

# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/socket.py
# class TimeoutError(socket.timeout):
#     """A socket timeout happened."""
# 
# @contextlib.contextmanager
# def convert_eof():
#     """A context manager to convert some socket errors into EOFError."""
#     try:
#         yield
#     except ConnectionResetError:
#         raise EOFError
#     except BrokenPipeError:
#         raise EOFError
#     except OSError as exc:
#         if exc.errno in EOF:
#             raise EOFError
#         raise


# Path: PyDevRemoteDebug/ptvsd-4.1.3/ptvsd/ipcjson.py
import errno
import itertools
import json
import os
import os.path
import sys
import time
import traceback
            import thread
            import _thread as thread
from socket import create_connection
from .socket import TimeoutError, convert_eof
    from encodings import ascii

def _str_or_call(m):
    # TODO: Use callable() here.
    try:
        call = m.__call__
    except AttributeError:
        return str(m)
    else:
        return str(call())


class InvalidHeaderError(Exception):
    # TODO: docstring
    pass


class InvalidContentError(Exception):
    # TODO: docstring
    pass


class SocketIO(object):
    # TODO: docstring

    def __init__(self, *args, **kwargs):
        port = kwargs.pop('port', None)
        socket = kwargs.pop('socket', None)
        own_socket = kwargs.pop('own_socket', True)
        logfile = kwargs.pop('logfile', None)
        if socket is None:
            if port is None:

                raise ValueError(
