'Set communication parameters on opened port.'

def _reconfigure_port(self):

    if (self._socket is None):
        raise SerialException('Can    only    operate    on    open    ports')
    if (self._write_timeout is not None):
        raise NotImplementedError('write_timeout    is    currently    not    supported')
    if (not (0 < self._baudrate < (2 ** 32))):
        raise ValueError('invalid    baudrate:    {!r}'.format(self._baudrate))
    self._rfc2217_port_settings['baudrate'].set(struct.pack('!I', self._baudrate))
    self._rfc2217_port_settings['datasize'].set(struct.pack('!B', self._bytesize))
    self._rfc2217_port_settings['parity'].set(struct.pack('!B', RFC2217_PARITY_MAP[self._parity]))
    self._rfc2217_port_settings['stopsize'].set(struct.pack('!B', RFC2217_STOPBIT_MAP[self._stopbits]))
    items = self._rfc2217_port_settings.values()
    if self.logger:
        self.logger.debug('Negotiating    settings:    {}'.format(items))
    timeout = Timeout(self._network_timeout)
    while (not timeout.expired()):
        time.sleep(0.05)
        if (sum((o.active for o in items)) == len(items)):
            break
    else:
        raise SerialException('Remote    does    not    accept    parameter    change    (RFC2217):    {!r}'.format(items))
    if self.logger:
        self.logger.info('Negotiated    settings:    {}'.format(items))
    if (self._rtscts and self._xonxoff):
        raise ValueError('xonxoff    and    rtscts    together    are    not    supported')
    elif self._rtscts:
        self.rfc2217_set_control(SET_CONTROL_USE_HW_FLOW_CONTROL)
    elif self._xonxoff:
        self.rfc2217_set_control(SET_CONTROL_USE_SW_FLOW_CONTROL)
    else:
        self.rfc2217_set_control(SET_CONTROL_USE_NO_FLOW_CONTROL)
