'Like ``attach``, but returns the underlying socket-like object for the
HTTP request.
Args:
container (str): The container to attach to.
params (dict): Dictionary of request parameters (e.g. ``stdout``,
``stderr``, ``stream``).
ws (bool): Use websockets instead of raw HTTP.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.'

@utils.check_resource('container')
def attach_socket(self, container, params=None, ws=False):

    if (params is None):
        params = {'stdout': 1, 'stderr': 1, 'stream': 1}
    if ws:
        return self._attach_websocket(container, params)
    headers = {'Connection': 'Upgrade', 'Upgrade': 'tcp'}
    u = self._url('/containers/{0}/attach', container)
    return self._get_raw_response_socket(self.post(u, None, params=self._attach_params(params), stream=True, headers=headers))
