<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def bind(self, address):
        '''
        Alter the local address with which this socket is associated.
        The address parameter is a 2-tuple consisting of an IP address
        and port number. 

        NB: this method fails and returns -1 if the requested port
        to bind to is already in use but does *not* check that the
        address is valid.  
        '''
        portset = _gather_ports().union(ApplicationLayer._emuports())
        if address[1] in portset:
            log_warn("Port is already in use.")
            return -1

        oldid = self._sockid()
        # block firewall port
        # set stack to only allow packets through for addr/port
        self._local_addr = _normalize_addrs(address)
        # update firewall and pcap filters
        self.__set_fw_rules()
        ApplicationLayer._registry_update(self, oldid)
        return 0